3.5 Token Validation (Assertion Flow)
Section 3 — Player Management
3.5 Token Validation (Assertion Flow)
Scope
Defines the short-lived, audience-restricted player assertion flow used to authenticate third-party apps (e.g., Cloud Save) without exposing write-capable game keys or write-scoped JWTs.
Summary
Gamers Lab issues two JWTs to the game client in a step-by-step process:
- A normal game JWT for GL writes.
- A short-lived, audience-bound assertion token for third-party identity verification.
The third-party app introspects the assertion with Gamers Lab using its own read API key that
has allow_auth enabled. No API key is ever embedded in the assertion.
Purpose
This second auth method allows game clients to authenticate into third-party applications
without sharing a write-authorized JWT or the X-Game-Key. Instead, the game client fetches a
second JWT that is tightly scoped to a specific third-party application by name and used for
authorization purposes only.
The third-party application must register at Gamers Lab first and request an X-API-Key
(read-only key), and the game owner must enable third-party authorization. This allows game
clients to safely sign players in to third-party applications without compromising sensitive
information, while allowing third-party applications to verify that a player is a registered
member of a specific game.
Actors and Keys
- Game client: holds the player JWT used for game data writes.
- Gamers Lab API: issues and validates JWTs.
- Third-party app (e.g. Cloud Save): holds a tenant API key with
allow_auth=true. - Tenant API key: stored in
bus_tenant_api_keyswithallow_authflag.
Tokens
Game JWT (player scope):
- Used for normal game API writes.
- Issued during player login.
Assertion JWT (verify scope):
- Short TTL: 120 seconds.
audmust equal the tenant API key name.- Scope is
verifyand auth type isplayer. - Contains
tenant_id,player_id,player_role,auth_provider, and optionalemail. - Does not contain any API key or secret.
Endpoints
POST /api/player-auth/jwt/exchange- Requires
Authorization: Bearer <player_jwt>. - Accepts
audience(string name of the third-party API key). - Issues the short-lived assertion token.
- Requires
POST /api/player-auth/jwt/validate- Requires
X-API-Keywithallow_auth=true. - Accepts the assertion token and validates it online.
- Requires
Flow
- Player logs in and receives the normal game JWT.
- Game client calls
/api/player-auth/jwt/exchangewith the player JWT and theaudiencestring (API key name). - Gamers Lab issues the assertion JWT with
aud=audience,scope=verify, TTL 120s. - Game client sends the assertion JWT to the third-party app.
- Third-party app calls
/api/player-auth/jwt/validatewith itsX-API-Keyand the assertion JWT. - Gamers Lab validates the assertion online and returns the player identity claims for that tenant.
- Third-party app mints its own session JWT for future calls.
Validation Rules
Exchange (/exchange):
- Player JWT must be valid and have
auth_type=playerandscope=player. tenant_idandplayer_idmust be present.- The current player profile must still resolve to an active account.
- The player must not currently be banned from the tenant.
audiencemust be provided; this is the API key name.
Validate (/validate):
- API key must be valid and have
allow_auth=true. - Assertion JWT must validate in a single pass for signature, issuer, expiry, and
aud. - Assertion JWT must have
auth_type=playerandscope=verify. - Assertion
tenant_idmust match API key tenant. - Assertion
audmust match the API key name used in theX-API-Keyrequest.
Security Notes
- The assertion is short-lived (120 seconds) and cannot be used for GL writes.
- The assertion is bound to a specific third-party API key name via
aud. /exchangere-checks current active-profile state and tenant bans before minting an assertion./validateenforces the assertion audience during JWT validation itself; it does not do a second unvalidated audience parse.- The API key
X-API-Keyitself is never sent to the game client. - The game client should never expose any keys to third parties.
- Introspection is online-only; third parties must call
/validate(no local JWKS verification).
Code References
- Exchange and validation:
GamersLabRestAPI/PlayerAuth/Controllers/PlayerTokenValidationController.cs - JWT generation/validation:
GamersLabRestAPI/Shared/Service/JwtService.cs - API key allow-auth claim:
GamersLabRestAPI/Saas/Business/Constants/ClaimTypes.cs - API key middleware allowlist:
GamersLabRestAPI/Saas/ApiKeys/Middleware/ApiKeyUseCaseMiddleware.cs