Auth Service uses a two-token model: a short-lived, stateless JWT access token that clients present on every API call, and a long-lived opaque refresh token stored server-side that can be exchanged for a fresh access token without re-authentication. This separation keeps the blast radius of a leaked access token small (it expires in minutes) while allowing sessions to stay alive for days without prompting the user to log in again.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ricardomb-tech/auth-service/llms.txt
Use this file to discover all available pages before exploring further.
JWT Configuration
JWT properties are bound fromapplication.properties into the JwtProperties record under the auth.jwt.* prefix. The record validates all values at startup — a blank secret or an out-of-range TTL will abort the application immediately rather than silently accepting an insecure configuration.
The active HS256 signing secret. All new access tokens are signed with this key; incoming tokens are verified against it first.Sourced from the
JWT_SECRET_CURRENT environment variable. Must not be blank — JwtProperties throws IllegalStateException at startup if it is.The previous signing secret, accepted only for signature verification during a rolling key rotation. Tokens signed with this key are still considered valid until they expire, giving in-flight clients time to exchange them for tokens signed with the new current key.Sourced from
JWT_SECRET_PREVIOUS. Defaults to an empty string (rotation inactive). Safe to leave blank when not rotating.Lifetime of each issued access token. Accepts any
java.time.Duration-compatible string (e.g. 15m, 1h, 30m).Default: 15mConstraint: Must be a positive duration and cannot exceed 1d. JwtProperties rejects values outside this range at startup.The value placed in the
iss claim of every issued JWT.Default: auth-serviceGenerating a Secure Secret
JWT_SECRET_CURRENT.
JWT Claims
Every access token issued by Auth Service contains the following claims:| Claim | Type | Description |
|---|---|---|
sub | string (UUID) | The internal account identifier |
email | string | The account’s verified email address |
roles | string[] | Array of granted roles, e.g. ["USER"] or ["USER","ADMIN"] |
iss | string | Token issuer — value of auth.jwt.issuer (default auth-service) |
iat | number | Issued-at timestamp (Unix epoch seconds) |
exp | number | Expiry timestamp (Unix epoch seconds) |
Zero-Downtime Secret Rotation
The dual-secret design (secret-current / secret-previous) lets you rotate the HS256 signing key without forcing all current users to re-authenticate. During a rotation window, the service signs new tokens with the incoming key while still accepting tokens signed by the outgoing key.
Generate the new secret
Create a fresh 256-bit secret and note the current value of
JWT_SECRET_CURRENT:Promote the current secret to previous
Set
JWT_SECRET_PREVIOUS to the current value of JWT_SECRET_CURRENT. This tells Auth Service to keep accepting tokens that were signed before the rotation.Deploy the updated configuration
Restart Auth Service (or perform a rolling deployment) with both environment variables set. Immediately after restart:
- All new access tokens are signed with the new
JWT_SECRET_CURRENT. - Existing tokens signed with the previous key are still accepted until they expire.
Wait for the rotation window to close
Wait for the duration of
auth.jwt.access-ttl (default 15 minutes). After this window, no tokens signed with the old secret can still be in circulation.Refresh tokens are opaque (not JWTs) and are stored in the database — they are unaffected by JWT secret rotation. Only the short-lived access tokens need to be re-issued after the rotation window.
Token Lifetime Configuration
Refresh token and email-related token TTLs are bound fromapplication.properties into the AuthTokenProperties record under the auth.token.* prefix. These can be overridden per environment without changing code.
How long an email verification token remains valid after it is issued. After this window, the user must request a new verification email.Default:
24hLifetime of an opaque refresh token. A user who has not used the service for longer than this duration will need to log in again.Default:
7dConstraint: Must be a positive duration and cannot exceed 90d.How long a password-reset token remains valid after it is issued. After this window, the user must submit a new forgot-password request.Default:
1h