Endpoint
Request
This endpoint requires no request body. Send an empty POST request:Response
The key ID (kid) of the newly created signing key
Example Response
Key Rotation Behavior
When you rotate the JWT signing key:- New key created: A new signing key with a unique
kidis generated using cryptographically secure random bytes - Old keys retained: Previous signing keys remain available for token verification
- New tokens signed: All newly issued tokens (via
/v1/auth/tokenor/v1/auth/token/refresh) will use the new key - Backward compatibility: Existing tokens signed with old keys remain valid and can be verified until they expire
Key Structure
Each signing key consists of:kid(Key ID): UUID v4 identifier included in JWT headerssecret: 16 bytes of cryptographically random data used for HS256 signing
src/qauth.rs:76-80:
Use Cases
Security Rotation
Rotate keys periodically as part of security best practices
Key Compromise
Immediately rotate if you suspect a signing key has been compromised
Zero-Downtime Updates
Rotate keys without invalidating existing user sessions
Compliance
Meet regulatory requirements for periodic key rotation
Implementation Details
The rotation mechanism fromsrc/qauth.rs:310-321:
Token Verification
During token validation (src/qauth.rs:396-421), the system:
- Iterates through all signing keys in reverse order (newest first)
- Attempts to decode the JWT with each key
- Returns claims if signature verification succeeds
- Checks the token’s
kidheader to optimize lookups
Best Practices
Monitor Token Expiry
After rotation, monitor for tokens approaching expiry. Most tokens expire within 15 minutes (access) or 24 hours (refresh)
Error Responses
| Status Code | Error | Description |
|---|---|---|
400 | Config | Failed to acquire write lock on signing keys |
500 | Internal Error | Unexpected error during key generation |
Example Error
Related Endpoints
Issue Tokens
Obtain access and refresh tokens with the current signing key
Introspect Tokens
Verify token signatures against all active signing keys
Revoke Tokens
Explicitly revoke tokens by JTI
Refresh Tokens
Exchange refresh tokens for new access tokens (signed with current key)