RFC 7519 — JSON Web Token (JWT)
Implemented (via github.com/golang-jwt/jwt/v5)
Source: docs/oauth/RFC_7519.md
RFC 7519 — JSON Web Token (JWT) ¶
Status: Standards Track
Published: 2015-05
L-tier / T-tier: L1 · T5 (issue) + T7 (verify)
OneAuth coverage: Implemented (viagithub.com/golang-jwt/jwt/v5)
JOSE family: JWS · JWE · JWK · JWA · JWT
See also:RFC_9068.md·LANDSCAPE.md
In one sentence ¶
JWT is the claim convention layered on JWS (or JWE) — a tiny set of
standardized claim names (iss, sub, aud, exp, iat, jti) that lets
verifiers reason about token identity, lifetime, and audience without
agreeing on anything else.
What problem does it solve? ¶
| Without JWT | With JWT |
|---|---|
Every signed-token format invents its own field names — expires_at vs expiry vs exp_unix |
Six canonical claim names; libraries everywhere agree |
| Audience checks (“is this token for me?”) are vendor-specific | aud claim with standardized comparison semantics |
| Lifetime checks (“is this token expired?”) are vendor-specific | exp claim with standardized clock-skew handling |
| Reusing the same token shape across signing (JWS) and encryption (JWE) is ad-hoc | JWT specifies the JOSE wrapper independence |
JWT is small. The RFC is 30 pages but the actual claim spec is two
sections. Its value is the convention, not the cryptography (which JWS/JWE
handle).
Relatable example ¶
Decode any modern OAuth Bearer token at jwt.io — the
center pane shows the claim envelope:
{
"iss": "https://accounts.google.com",
"azp": "32555350559.apps.googleusercontent.com",
"aud": "32555350559.apps.googleusercontent.com",
"sub": "100123456789012345678",
"email": "sri@example.com",
"email_verified": true,
"at_hash": "x7vplJ-rh-OnePf-XKkLOA",
"iat": 1717000000,
"exp": 1717003600,
"nonce": "abc..."
}
iss, aud, sub, iat, exp are JWT (registered claims). email,
email_verified, at_hash, azp, nonce are OIDC additions (public
claims registered by OIDC Core). This is the universal shape that lets every
OAuth library agree on the basics.
Key concepts ¶
- Three claim categories: registered (JWT-defined: iss, sub, aud,
exp, nbf, iat, jti), public (IANA-registered by other specs like OIDC,
RFC 9068), private (vendor-specific, no registration). expandnbfuse Unix timestamps in seconds (not millis, not
ISO 8601). One of the most-asked questions about JWT.audcan be a string OR an array of strings. Verifiers MUST handle
both. Failing this is a common source of validation bugs.jti(JWT ID) supports revocation lists and reuse detection. Without
jti, you can’t blacklist a specific token.- JWT is JOSE-agnostic. A JWT can be carried in JWS (signed, the
common case) or JWE (encrypted, rare in OAuth). The token format and the
crypto envelope are decoupled by design.
Wire example ¶
A full signed JWT, header + payload + signature, on the wire as JWS Compact
Serialization:
eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleS0yMDI1LWp1biIsInR5cCI6IkpXVCJ9 ← header
.
eyJpc3MiOiJodHRwczovL2FzLmV4YW1wbGUuY29tIiwic3ViIjoidXNlci00MiIs
ImF1ZCI6Imh0dHBzOi8vYXBpLmV4YW1wbGUuY29tIiwiZXhwIjoxNzUwMDAwMDAw
LCJpYXQiOjE3NDk5OTY0MDAsImp0aSI6IjQyZmEtYjAxNyIsInNjb3BlIjoicmVh
ZCB3cml0ZSJ9 ← payload
.
T8C2KFt9...rJZBg ← signature
Decoded:
HEADER : {"alg":"RS256","kid":"key-2025-jun","typ":"JWT"}
PAYLOAD : {
"iss": "https://as.example.com", ← registered (issuer)
"sub": "user-42", ← registered (subject)
"aud": "https://api.example.com", ← registered (audience)
"exp": 1750000000, ← registered (expiry, unix sec)
"iat": 1749996400, ← registered (issued at, unix sec)
"jti": "42fa-b017", ← registered (JWT ID, for revoke)
"scope": "read write" ← public, registered by RFC 8693
}
The verifier checks: signature valid (JWS step), iss matches expected
issuer, aud includes me, exp is in the future, nbf (if present) is in
the past. Only then trust the other claims.
Where it lands on the OAuth abstraction ¶
- L1 token format. JWT is the convention; JWS is the cryptographic
envelope. - T5 (issue) — the AS constructs claims and signs.
- T7 (verify) — the RS validates signature, then validates
iss/aud/
exp/nbfper JWT rules. - JWT is the alternative to opaque tokens + introspection (RFC 7662).
Local verification trades introspection round-trips for ~ms of crypto
per request.
OAuth 2.0 status ¶
JWT published 2015 — after 2.0 (2012). Not part of bare 6749; 6749 says
access tokens are opaque to clients. JWT became the de-facto access-token
format in 2.0 deployments because of the local-verification win.
Until RFC 9068 (2021), there was no standard for what claims an OAuth
access token should carry — every IdP did its own thing within JWT’s claim
framework. RFC 9068 fixed this by standardizing the access-token claim set
(see RFC_9068.md).
OAuth 2.1 status ¶
Same. 2.1 doesn’t mandate JWT tokens. RFC 9068’s profile is referenced but
not required. Opaque tokens + introspection remain a 2.1-conformant option.
In practice: if you’re shipping a new AS in 2025, you’ll almost certainly
ship JWT access tokens following 9068, simply because that’s what the
ecosystem expects.
Migration path (opaque ↔ JWT) ¶
Most ASes ship one or the other from day one. Migration between them is
possible but operationally noisy:
- Opaque → JWT: existing tokens stay opaque; new tokens are JWT. RS
needs to handle both (try JWT verify first, fall back to introspection,
or look at token shape). Deprecate opaque after expiry of all old
tokens. - JWT → Opaque: rarer migration. Reasons are usually centralization of
revocation control. Same dual-handling pattern.
Both directions tolerate the dual-handling window. OneAuth supports JWT
issuance natively; opaque-token support exists for completeness but JWT is
the default.
OneAuth status ¶
| 7519 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
| JWT issuance | Implemented | apiauth/token_validator.go (jwtIssuer.CreateAccessToken), apiauth/asymmetric_jwt_test.go |
Via github.com/golang-jwt/jwt/v5 |
| JWT verification (full RFC 7519 §7.2 checks) | Implemented | apiauth/jwt_helpers.go (accessTokenParserOptions, matchesAudience); full claim validation across handlers |
iss, aud, exp, iat enforced. exp is required since 0.1.45 (jwt.WithExpirationRequired) |
aud string OR array handling |
Implemented | apiauth/audience_test.go arrayAudClaims tests both shapes |
Multi-audience tokens validate correctly |
iss validation against expected issuer |
Implemented | Per-handler; AS issues with full issuer URL | — |
exp validation with clock skew |
Implemented | golang-jwt allows configurable skew | OneAuth uses library defaults for skew. A token with no exp is refused since 0.1.45 |
jti for revoke / reuse detection |
Partial | Issued on tokens; revocation list via core.TokenBlacklist (consumed in apiauth/token_validator.go) and apiauth/RevocationHandler |
Tied to refresh-token family revoke per core.ErrTokenReused |
| Custom claims (private + RFC 9396 RAR) | Implemented | core/authorization_details.go for RAR; per-claim helpers in apiauth/custom_claims_test.go |
authorization_details claim carries RAR. CustomClaimsFunc can’t set the standard claims, and since 0.1.45 it can’t set nbf, scope, azp, sid, act or may_act either (issuanceReservedClaims) |
| Token-kind separation (RFC 8725 §3.11) | Implemented | apiauth/jwt_helpers.go checkAccessTokenKind |
A JWT signed with the same key is refused as an access token when it is another kind: logout tokens (typ: logout+jwt) and ID-JAGs by typ header, browser sessions by a type claim other than access (0.1.45), and Keycloak ID tokens by a typ claim other than Bearer or DPoP (0.1.46) |
| Tenant key binding | Implemented | apiauth/jwt_helpers.go checkTenantKey |
Since 0.1.45 a key registered to a client verifies only tokens carrying that client_id. The validator’s own key and keys with no owner (a remote JWKS) are exempt |
Related RFCs ¶
- RFC 7515 JWS — the signing envelope JWT almost always rides in
- RFC 7516 JWE — the encryption envelope JWT can ride in (rare)
- RFC 7517 JWK — where verifiers find the public key
- RFC 7518 JWA — the algorithm vocabulary
- RFC 9068 — the JWT Profile for OAuth 2.0 Access Tokens
- RFC 7662 — Token Introspection; the opaque-token alternative
- RFC 7523 — JWT bearer profile for client auth and assertion grants
- OIDC Core — id_token shape (a specific JWT profile for identity)
Spec links ¶
- Datatracker: rfc7519
- RFC editor copy
- Errata search
- IANA JWT Claims registry — the live claim catalog