This documentation is for a previous version of Cerbos. Choose 0.34.0 from the version picker at the top right or navigate to https://docs.cerbos.dev for the latest version.

AuxData block

The auxData block configures the auxiliary data sources that can be referenced in policy conditions.

JWT

Cerbos supports reading claims from a JWT issued by an authentication system. This helps reduce the boilerplate on the client side to extract the claims from a JWT and add them as attributes to the Cerbos API request. (See api:index.adoc and Auxiliary Data for more information on how to craft the API request and access the JWT claims in policies.)

In order to verify the JWT, the Cerbos instance must have access to the appropriate keysets. They can be fetched from a URL or read from the local file system. Verification involves checking that the signature is valid and that the token has not expired.

Using multiple keysets
auxData:
  jwt:
    keySets:
      - id: ks1 # Unique ID that can be used in API requests to indicate the keyset to use to verify a particular token.
        remote: # Fetch from a JWKS URL.
          url: https://domain.tld/.well-known/keys.jwks
      - id: ks2
        remote:
          url: https://other-domain.tld/.well-known/keys.jwks
          refreshInterval: 1h # Explicitly set the refresh interval.
      - id: ks3
        local: # Load from a local file
          file: /path/to/keys.jwks
      - id: ks4
        local: # Load from a base64-encoded key data defined inline.
          data: BASE64-ENCODED-KEY-DATA
      - id: ks5
        local:
          file: /path/to/keys.pem
          pem: true # Treat the file (or data) as PEM.
When multiple keysets are defined in the configuration file, all API requests must include the keyset ID along with the JWT. When only a single keyset is defined in the configuration, then the keyset ID can be dropped from the API requests.

When keysets are fetched from a remote source, if the refreshInterval is not defined in the configuration, Cerbos will respect the Cache-Control and Expiry headers returned from the remote source when determining the refresh interval. If none of these data points are available, then the default refresh interval is one hour.

You can disable JWT verification by setting disableVerification to true. When verification is disabled, Cerbos will not perform cryptographic verification of the JWT but the exp and nbf claims are still checked to ensure that the token is valid. You can configure the acceptable time skew for those claims by setting acceptableTimeSkew to a positive time duration.

Disabling JWT verification is not recommended because it makes the system insecure by forcing Cerbos to evaluate policies using potentially tampered data. Similarly, it’s not recommended to set acceptableTimeSkew to more than a few seconds.
auxData:
  jwt:
    disableVerification: true
    acceptableTimeSkew: 2s

Cerbos maintains an in-memory cache of verified JWTs to avoid repeating the cryptographic verification step on each request. Cached tokens are still validated on each request to make sure they are still valid for use. You can increase the size of the cache by setting cacheSize.

auxData:
  jwt:
    cacheSize: 256
    keySets:
      - id: default
        remote:
          url: https://domain.tld/.well-known/keys.jwks

Some legacy authentication systems have key sets that do not contain alg or kid fields. Not having these fields defined is a security risk and the default behaviour of Cerbos is to fail the parsing of JWT. If you are aware of the risks and still want to enable those tokens to be parsed, set the optionalAlg and optionalKid options.

auxData:
  jwt:
    keySets:
      - id: default
        remote:
          url: https://domain.tld/.well-known/keys.jwks
        insecure:
          optionalAlg: true # Set to true only if the keyset doesn't have an alg field
          optionalKid: true # Set to true only if the keyset doesn't have a kid field