Login.gov · API Governance Rules

Login.gov API Rules

Spectral linting rules defining API design standards and conventions for Login.gov.

7 Rules error 5 warn 2
View Rules File View on GitHub

Rule Categories

login

Rules

warn
login-gov-title-case-summaries
Operation summaries should use Title Case (Login.gov OIDC/SAML house style).
$.paths[*][*].summary
warn
login-gov-operation-id-camel-case
operationId should be camelCase.
$.paths[*][*].operationId
error
login-gov-require-tag
Every operation must be tagged.
$.paths[*][*]
error
login-gov-min-22-char-state-nonce
The `state` and `nonce` parameters MUST be at least 22 characters long.
$.paths['/openid_connect/authorize'].get.parameters[?(@.name=='state' || @.name=='nonce')].schema
error
login-gov-require-prompt-select-account
Authorization requests must declare prompt=select_account.
$.paths['/openid_connect/authorize'].get.parameters[?(@.name=='prompt')].schema.enum
error
login-gov-response-type-code-only
Login.gov supports only response_type=code (implicit flow is not supported).
$.paths['/openid_connect/authorize'].get.parameters[?(@.name=='response_type')].schema.enum
error
login-gov-bearer-on-userinfo
The userinfo endpoint must require bearer authentication.
$.paths['/api/openid_connect/userinfo'].get

Spectral Ruleset

Raw ↑
extends:
- spectral:oas
rules:
  login-gov-title-case-summaries:
    description: Operation summaries should use Title Case (Login.gov OIDC/SAML house style).
    given: $.paths[*][*].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: '^[A-Z][A-Za-z0-9]*( [A-Z0-9][A-Za-z0-9/.-]*)*$'

  login-gov-operation-id-camel-case:
    description: operationId should be camelCase.
    given: $.paths[*][*].operationId
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]+$'

  login-gov-require-tag:
    description: Every operation must be tagged.
    given: $.paths[*][*]
    severity: error
    then:
      field: tags
      function: truthy

  login-gov-min-22-char-state-nonce:
    description: The `state` and `nonce` parameters MUST be at least 22 characters long.
    given: $.paths['/openid_connect/authorize'].get.parameters[?(@.name=='state' || @.name=='nonce')].schema
    severity: error
    then:
      field: minLength
      function: truthy

  login-gov-require-prompt-select-account:
    description: Authorization requests must declare prompt=select_account.
    given: $.paths['/openid_connect/authorize'].get.parameters[?(@.name=='prompt')].schema.enum
    severity: error
    then:
      function: enumeration
      functionOptions:
        values:
        - select_account

  login-gov-response-type-code-only:
    description: Login.gov supports only response_type=code (implicit flow is not supported).
    given: $.paths['/openid_connect/authorize'].get.parameters[?(@.name=='response_type')].schema.enum
    severity: error
    then:
      function: enumeration
      functionOptions:
        values:
        - code

  login-gov-bearer-on-userinfo:
    description: The userinfo endpoint must require bearer authentication.
    given: $.paths['/api/openid_connect/userinfo'].get
    severity: error
    then:
      field: security
      function: truthy