Authenticates a MoM-issued seat token inside the GM, with no per-event round trip for the common case.
Two things are checked, and they come from different places on purpose:
default-seat-ttl-ms, which bounds how stale a revocation can be.Everything fails CLOSED: if the keys or the seat cannot be obtained, the caller is refused with 503, never admitted on a guess. The result is MoM's own :caller envelope, the shape game.gm.authorization already reads.
Authenticates a MoM-issued seat token inside the GM, with no per-event round trip for the common case. Two things are checked, and they come from different places on purpose: 1. WHICH SEAT. The token is an RS256 JWT signed with a private key only MoM holds. The GM verifies it against MoM's published public keys (/.well-known/jwks.json), so it can verify a token but never mint one. The JDK does the crypto; there is no JWT library here. 2. WHAT THE SEAT MAY DO. The token carries no roles, so a role granted or revoked after minting would otherwise be invisible. The GM asks MoM for the seat (GET /admin/games/:game-name/seats/:membership-id) and caches the answer for `default-seat-ttl-ms`, which bounds how stale a revocation can be. Everything fails CLOSED: if the keys or the seat cannot be obtained, the caller is refused with 503, never admitted on a guess. The result is MoM's own :caller envelope, the shape game.gm.authorization already reads.
(authenticate opts token)Verifies token and resolves the seat it names.
opts: {:mom-url :game-id :game-name} plus an optional :seat-ttl-ms.
{:caller <MoM :caller envelope> :claims ..} on success, else {:error {:status :code :message}}: 401 for a bad token or a seat that no longer exists, 403 for a token that is for another game, 503 when MoM cannot be asked.
Verifies `token` and resolves the seat it names.
opts: {:mom-url :game-id :game-name} plus an optional :seat-ttl-ms.
{:caller <MoM :caller envelope> :claims ..} on success, else {:error {:status
:code :message}}: 401 for a bad token or a seat that no longer exists, 403 for a
token that is for another game, 503 when MoM cannot be asked.How long a seat's roles are trusted before MoM is asked again.
How long a seat's roles are trusted before MoM is asked again.
(reset-caches!)Forgets every cached key and seat. For tests and for an operator who needs a revocation to take effect now.
Forgets every cached key and seat. For tests and for an operator who needs a revocation to take effect now.
(verify-token {:keys [mom-url game-id]} token)Verifies a seat token's signature, expiry and claims against MoM's published keys.
{:claims {:membership/id .. :game/id .. :player/name .. :exp ..}} on success, else
{:error {:status :code :message}}: 401 :invalid-token, 403 :wrong-game for a
genuine MoM token that names another game, 503 :identity-unavailable when MoM's keys
cannot be had. Exactly one algorithm is accepted, RS256; none and HMAC tokens are
refused, so a token claiming another algorithm is never checked against these keys.
Verifies a seat token's signature, expiry and claims against MoM's published keys.
{:claims {:membership/id .. :game/id .. :player/name .. :exp ..}} on success, else
{:error {:status :code :message}}: 401 :invalid-token, 403 :wrong-game for a
genuine MoM token that names another game, 503 :identity-unavailable when MoM's keys
cannot be had. Exactly one algorithm is accepted, RS256; `none` and HMAC tokens are
refused, so a token claiming another algorithm is never checked against these keys.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |