Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Verification proceeds in order, cheapest first:
1. **Decode.** The token must be three base64url segments carrying a JSON header and JSON payload. Malformed input fails here with no network traffic.
2. **Expiry.** The `exp` claim must be present and in the future, judged against the local clock with no skew allowance. (Some SDKs offer an opt-in flag that skips this check for callers that need to inspect expired tokens.)
3. **Route.** If the header declares an asymmetric signing algorithm the SDK can verify locally (for example ES256 or RS256) and names a key id (`kid`), verification is local. Any other token - one signed with the legacy HS256 shared secret, or missing an algorithm or key id - is verified by calling [Get User](auth.session.get_user) instead: a successful response proves the server accepts the token, and the claims from step 1's decode are returned.
4. **Resolve the key.** The `kid` is looked up in the cached JWK Set. An unknown `kid` forces a refetch even when the cache is fresh, so freshly rotated signing keys are usable immediately. If the refetched document still lacks the `kid`, fall back to server-side verification as in step 3.
4. **Resolve the key.** The `kid` is looked up in the cached JWK Set. An unknown `kid` forces a refetch even when the cache is fresh, so freshly rotated signing keys are usable immediately. SDKs should rate-limit these forced refetches with exponential backoff: while consecutive forced fetches fail to resolve the `kid` that forced them, double the wait before the next one (for example one second up to a sixteen-second backstop), and clear the wait once a fetch resolves its `kid`. Misses inside the wait resolve as unknown and take the step 3 fallback, so a storm of attacker-minted `kid`s decays to a bounded fetch rate while a genuine rotation still verifies - immediately when the backoff is clear, via the fallback during a storm. If the refetched document still lacks the `kid`, fall back to server-side verification as in step 3.
5. **Verify.** The signature is checked over the `header.payload` signing input using the matched public key. Success returns the claims, the decoded header and the raw signature bytes. Failure is an invalid-signature error.

The JWK Set is cached in the client for ten minutes, matching the `Cache-Control: public, max-age=600` the endpoint serves. The cache is shared across calls, and concurrent misses should coalesce into a single fetch.
Expand Down