Skip to content

Session token claims ​

Environment Variable draft xyz environment security auth jwt

JWT_TYPE, JWT_ISSUER and JWT_AUDIENCE set the typ, iss and aud claims of signed user tokens.

Resource and sources

The user cookie XYZ signs, whether at login (redirect), on cookie renewal or in the auth module, merges the claims returned by jwtClaims():

VariableClaimDefault
JWT_TYPEtypsession
JWT_ISSUERissxyz
JWT_AUDIENCEaudxyz

JWT_AUDIENCE is split on commas, so aud is always an array, eg. JWT_AUDIENCE=xyz,other-service gives ["xyz", "other-service"].

The claims let another service authenticate users through XYZ by verifying the token type, issuer and audience. A service that verifies against fixed names needs JWT_ISSUER and JWT_AUDIENCE set to match. XYZ itself does not check the claims when it verifies a token.

Tokens from /api/user/token and API keys from /api/user/key do not carry these claims; an API key is marked by its api claim instead. Signing them with the claims is tracked in #3166.

The defaults are applied in processEnv.js with ??=, unlike most XYZ defaults which use ||=. An empty value, as declared by a varlock schema without a value, is kept rather than replaced, and gives an empty claim. The jwtClaims JSDoc still says the variables must be configured for the claims to be included; the defaults make that obsolete (#3155).

Changing these values invalidates tokens for any service which verifies the previous claims.

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.