Skip to content

Tokens and cookies ​

VariableDefaultPurpose
SECRETnoneSecret string which signs user tokens.
SECRET_KEYnonePEM private key, inline or as a key file, used instead of SECRET.
SECRET_ALGORITHMHS256, or RS256 with SECRET_KEYToken signing algorithm.
TITLEGEOLYTIX | XYZName of the user cookie and the instance title.
COOKIE_TTL36000Lifetime of the user cookie and token, in seconds (10 hours).
COOKIE_PROPSsee belowAttributes of every cookie XYZ sets.

Signing ​

An instance with an ACL needs SECRET or SECRET_KEY. Without either, no token verifies and nobody can log in. Session cookies, cookie renewals and API keys are all signed with the same secret, so changing it logs out every user and invalidates every API key. The token claims are in Session token claims.

SECRET_KEY holds a PEM private key, as a secret manager provides it, or the path of a key file relative to XYZ_CWD. A value starting with -----BEGIN, after any leading whitespace, is used as the key itself. A key file which cannot be read stops the process at startup. The key replaces SECRET, and SECRET_ALGORITHM defaults to RS256 unless it is set.

dotenv
SECRET_KEY=keys/xyz_private.pem

Use an RSA or EC algorithm with a key, and an HMAC algorithm such as HS256 with a SECRET string.

The user token is stored in a cookie named after TITLE. A login redirect target is held in a <TITLE>_redirect cookie: for 60 seconds when a PRIVATE request is redirected to the login, and for 300 seconds when the login view is opened with a return_to param. TITLE is also the title parameter of view templates and the default workspace.key. Instances served from one domain and path need different titles, or their cookies collide.

COOKIE_TTL sets the cookie Max-Age and the token expiry at login and on each renewal through /api/user/cookie.

COOKIE_PROPS is appended to every cookie set by XYZ and the SAML app. The default is:

text
Secure; HttpOnly; SameSite=Strict; Path=<DIR or />

The cookie path follows DIR. A deployment served over plain HTTP must set COOKIE_PROPS without Secure, since browsers do not store secure cookies from such origins (most allow it on localhost):

dotenv
COOKIE_PROPS=HttpOnly; SameSite=Strict; Path=/

Cookies are removed with null; Max-Age=0 and the same attributes. A browser only replaces a cookie with the same path, so after a change of DIR or of the Path in COOKIE_PROPS, existing cookies stay until they expire.

Empty values ​

Unlike the other defaults, the COOKIE_PROPS default only applies when the variable is undefined. A varlock schema which declares COOKIE_PROPS without a value injects an empty string, and every cookie is set without attributes. Leave it out of the schema, or give it a value. An empty TITLE, COOKIE_TTL or SECRET_ALGORITHM takes the default.

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