Optional agentOptional audienceExpected JWT "aud" (Audience) Claim value(s).
REQUIRED: You can also provide the AUDIENCE environment variable.
Optional authTrue if a valid Access Token JWT should be required for all routes. Defaults to true.
Optional cacheCache configuration for OIDC discovery metadata and JWKS. Caching reduces network requests and improves performance, especially in MCD scenarios with multiple issuers.
Default behavior (if not specified):
Optional discovery?: { OIDC discovery metadata cache configuration. Caches responses from /.well-known/openid-configuration endpoints.
Optional maxMaximum number of issuer discovery metadata to cache. When this limit is reached, least recently used entries are evicted. Default: 100
Optional ttl?: numberTime-to-live for cached discovery metadata in milliseconds. Default: 600000 (10 minutes)
Optional jwks?: { JWKS (JSON Web Key Set) cache configuration. Caches responses from /.well-known/jwks.json endpoints.
Optional maxMaximum number of JWKS to cache. When this limit is reached, least recently used entries are evicted. Default: 100
Optional ttl?: numberTime-to-live for cached JWKS in milliseconds. Default: 600000 (10 minutes)
Optional cacheMaximum time (in milliseconds) between successful HTTP requests to the JWKS and Discovery endpoint. Default is 600000 (10 minutes).
Use cache.ttl instead for more granular control
Optional clockClock tolerance (in secs) used when validating the exp and iat claim.
Defaults to 5 secs.
Optional cooldownDuration in ms for which no more HTTP requests to the JWKS Uri endpoint will be triggered after a previous successful fetch. Default is 30000.
Optional dpopOptions to configure DPoP (Demonstration of Proof of Possession) validation.
If not provided or set to undefined, the following default values will be used:
{
enabled: true,
required: false,
iatOffset: 300, // 5 minutes
iatLeeway: 30, // 30 seconds
}
Optional issuerExpected JWT "iss" (Issuer) Claim value.
REQUIRED (if you don't include {@Link AuthOptions.issuerBaseURL})
You can also provide the ISSUER environment variable.
Optional issuerBase url, used to find the authorization server's app metadata per
https://datatracker.ietf.org/doc/html/rfc8414
You can pass a full url including .well-known if your discovery lives at
a non standard path.
REQUIRED (if you don't include {@Link AuthOptions.jwksUri} and
{@Link AuthOptions.issuer})
You can also provide the ISSUER_BASE_URL environment variable.
Optional jwksUrl for the authorization server's JWKS to find the public key to verify
an Access Token JWT signed with an asymmetric algorithm.
REQUIRED (if you don't include {@Link AuthOptions.issuerBaseURL})
You can also provide the JWKS_URI environment variable.
Optional maxMaximum age (in secs) from when a token was issued to when it can no longer be accepted.
Optional mcdMCD (Multiple Custom Domains) Support: Configure multiple issuers for JWT validation. When present, the SDK operates in MCD mode.
Examples:
Cannot be used with issuerBaseURL.
Optional secretSecret to verify an Access Token JWT signed with a symmetric algorithm. By default this SDK validates tokens signed with asymmetric algorithms.
Optional strictIf set to true the token validation will strictly follow
'JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens'
https://datatracker.ietf.org/doc/html/draft-ietf-oauth-access-token-jwt-12
Defaults to false.
Optional timeoutTimeout in ms for HTTP requests to the JWKS and Discovery endpoint. When reached the request will be aborted. Default is 5000.
Optional tokenYou must provide this if your tokens are signed with symmetric algorithms and it must be one of HS256, HS384 or HS512. You may provide this if your tokens are signed with asymmetric algorithms and, if provided, it must be one of RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES256K, ES384, ES512 or EdDSA (case-sensitive).
Optional validatorsPass in custom validators to override the existing validation behavior on standard claims or add new validation behavior on custom claims.
{
validators: {
// Disable issuer validation by passing `false`
iss: false,
// Add validation for a custom claim to equal a passed in string
org_id: 'my_org_123'
// Add validation for a custom claim, by passing in a function that
// accepts:
// roles: the value of the claim
// claims: an object containing the JWTPayload
// header: an object representing the JWTHeader
roles: (roles, claims, header) => roles.includes('editor') && claims.isAdmin
}
}
An instance of http.Agent or https.Agent to pass to the http.get or https.get method options. Use when behind an http(s) proxy.