RFC 7517 — JSON Web Key (JWK) / JSON Web Key Set (JWKS)
Implemented (keys/jwks_handler.go, keys/jwks_keystore.go)
Source: docs/oauth/RFC_7517.md
RFC 7517 — JSON Web Key (JWK) / JSON Web Key Set (JWKS) ¶
Status: Standards Track
Published: 2015-05
L-tier / T-tier: L1 · T0 (publish) + T7 (verify)
OneAuth coverage: Implemented (keys/jwks_handler.go,keys/jwks_keystore.go)
JOSE family: JWS · JWE · JWK · JWA · JWT
See also:docs/JWT_SIGNING.md·LANDSCAPE.md
In one sentence ¶
JWK is a JSON encoding of a single cryptographic key; JWKS is the JSON array
of those keys an AS publishes for verifiers to fetch — the format behind every
/.well-known/jwks.json endpoint on the internet.
What problem does it solve? ¶
| Without JWK/JWKS | With JWK/JWKS |
|---|---|
| RS verifies tokens against a hardcoded public key — rotation requires a config push to every RS | RS pulls the current public keys from a URL; rotation is a publish-side action |
| Public keys distributed as PEM (or DER, or SPKI, or PKIX) — N format dialects per implementation | One JSON shape; libraries everywhere |
kid (key ID) lookups need vendor-specific catalog formats |
Standardized — the JWKS is the catalog |
JWK/JWKS turns “public key distribution” from a deploy-time problem into a
runtime problem. That’s a huge operational win.
Relatable example ¶
Open any of these in a browser; you’re looking at a JWKS:
- Google: https://www.googleapis.com/oauth2/v3/certs
- Microsoft: https://login.microsoftonline.com/common/discovery/v2.0/keys
- GitHub Actions OIDC: https://token.actions.githubusercontent.com/.well-known/jwks
- Your local OneAuth-AS:
https://<as>/.well-known/jwks.json
Each one returns a JSON document like:
{
"keys": [
{
"kty": "RSA",
"use": "sig",
"kid": "934f...",
"alg": "RS256",
"n": "0vx7agoebGcQ...long_base64url_modulus...",
"e": "AQAB"
},
{
"kty": "EC",
"use": "sig",
"kid": "ec-2025-q1",
"alg": "ES256",
"crv": "P-256",
"x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
}
]
}
When your RS gets a JWT with kid=934f..., it finds the matching JWK in the
set and uses (n, e) to construct the RSA public key.
Key concepts ¶
kty(key type) is the discriminator.RSA,EC,OKP
(Ed25519/Ed448),oct(symmetric). Determines which other fields appear
(n/efor RSA,crv/x/yfor EC, etc.).useandkey_opsdistinguish signing keys from encryption keys.
use=sigis the OAuth norm.kidis the rotation enabler. The AS mints with one kid; publishes a
set containing current + previous (grace-period) kids; the verifier
matches headerkidto JWK in set.- Public keys only. A JWKS published at a
.well-knownURL must
contain only public key material — RSA modulus and exponent (n,
e), EC curve point (crv,x,y). Private fields (d,p,q,
dp,dq,qi) MUST NOT be published. Symmetric keys (oct) are
never published. - RFC 7638 thumbprints give canonical fingerprints for keys (used in
DPoP’scnf.jktclaim — see RFC 9449).
Wire example ¶
Setup-time (T0): AS publishes JWKS.
GET /.well-known/jwks.json HTTP/1.1
Host: as.example.com
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: public, max-age=3600
{
"keys": [
{ "kty": "RSA", "use": "sig", "kid": "rsa-2025-jun", "alg": "RS256",
"n": "...", "e": "AQAB" },
{ "kty": "EC", "use": "sig", "kid": "ec-2025-jun", "alg": "ES256",
"crv": "P-256", "x": "...", "y": "..." }
]
}
Verify-time (T7): RS receives a JWT, fetches JWKS, looks up kid.
JWT header: {"alg":"RS256","kid":"rsa-2025-jun","typ":"JWT"}
↓
RS reads kid → looks up entry in JWKS → reconstructs RSA public key from (n, e)
→ verifies JWS signature → trusts payload
Where it lands on the OAuth abstraction ¶
- L1 token format. JWK is the key-encoding sibling of JWS/JWE/JWT.
- T0 (publish) + T7 (verify). The AS publishes once at deploy; every RS
fetches at startup and on cache-miss. - Critical for rotation. Without
kid-driven JWKS, rotation requires a
config push everywhere; with it, rotation is just a publish-side event.
OAuth 2.0 status ¶
Not mandated by 6749. But the JWKS pattern is the way modern 2.0 ASes
distribute verification keys for JWT-shaped access tokens and id_tokens —
universal in practice.
RFC 8414 (AS Metadata) introduced jwks_uri as a standardized metadata
field, which makes JWKS effectively required for any AS that issues
JWT-shaped tokens to consumers that don’t share private state.
OAuth 2.1 status ¶
Same as 2.0 — not formally mandated, universally deployed for asymmetric
verification.
OneAuth status ¶
| 7517 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
/.well-known/jwks.json endpoint |
Implemented | keys/jwks_handler.go (JWKSHandler.ServeHTTP) |
Cached via Cache-Control: public, max-age=3600 and an ETag. Since 0.1.47 a 304 keeps both headers, and If-None-Match accepts lists, * and weak tags (etagMatches) |
RSA key type encoding |
Implemented | utils/jwk.go RSAPublicKeyToJWK → {kty:RSA, n, e, kid, alg, use} |
RS256 in production |
EC (P-256) key type encoding |
Implemented | utils/jwk.go ECDSAPublicKeyToJWK → {kty:EC, crv:P-256, x, y, kid, alg, use} |
ES256 supported |
OKP (Ed25519) key type, RFC 8037 |
Implemented for DPoP proof keys | utils/jwk.go Ed25519PublicKeyToJWK and okpJWKToPublicKey |
Added in 0.1.43 so DPoP proofs can carry Ed25519 keys. Only the Ed25519 curve parses. JWKSHandler publishes RS256 and ES256 keys only (utils.IsAsymmetricAlg), so no OKP key appears in oneauth’s own JWKS |
| RSA key size floor | Implemented | utils.CheckRSAKeySize, called by ParsePublicKeyPEM, ParsePrivateKeyPEM and rsaJWKToPublicKey |
Since 0.1.47 an RSA key under 2048 bits fails at load. JWKSKeyStore skips such a key in a remote JWKS and logs it |
| Symmetric keys (HS256) deliberately omitted | Compliant | keys.JWKSHandler doc comment: “Only asymmetric keys (RS256/ES256) are included — HS256 secrets are never exposed” |
CLAUDE.md “Gotchas” calls this out |
kid rotation with grace period |
Implemented | keys/kid.go KidStore, KidLister + CompositeKeyLookup; OneAuthConfig.KidStore; keys.JWKSHandler.RetiredKeys |
Since 0.1.47 oneauth’s own validator verifies a rotated key until its grace period ends. JWKSHandler now publishes retired keys from any kid store that lists (in-memory, FS, GORM, GAE, encrypted), and the reference server passes its own, so a remote resource server keeps the old key for the grace period too (issue 421) |
| Rotating the AS’s own signing key at runtime | Implemented | apiauth/signing_key.go RotatingSigningKey; OneAuthConfig.SigningKeySource, OwnKeyClientID |
Access tokens, ID tokens and logout tokens sign with the source’s current key, and the validator’s own key follows it. Tokens signed with the retired key verify through the kid store until the grace period ends. Reference server: jwt.key_rotation turns on POST /admin/signing-key/rotate behind admin auth; the rotated key lives in memory until restart (issue 507) |
| Remote JWKS fetcher with caching | Implemented | keys/jwks_keystore.go JWKSKeyStore |
Used when validating tokens from a foreign AS |
| RFC 7638 thumbprint computation | Implemented | utils/jwk_thumbprint.go |
Used for kid derivation and DPoP cnf.jkt |
| W3C Trace Context (SEP-414 / issue 254) | Implemented | keys/jwks_handler.go emits oneauth.jwks.serve span; keys/jwks_keystore.go emits oneauth.jwks.key_lookup / oneauth.jwks.refresh |
Tracing scaffolded throughout |
EncryptedKeyStorage for private keys at rest |
Implemented | keys/encrypted.go, keys/encrypted_kid.go |
Records are written as oaenc1: + nonce + AES-256-GCM, with AAD over client, alg and kid, so a ciphertext copied into another record won’t open. Since 0.1.46 a record that won’t decrypt is keys.ErrKeyDecrypt, and so is a plaintext secret unless AllowLegacyPlaintext is set; MigrateLegacy rewrites old records. EncryptedKidStorage (0.1.47) applies the same rules to retired keys. Public PEMs pass through |
The deliberate HS256 omission is a correctness property worth highlighting:
shared-secret algorithms have no public half, so there’s nothing legitimate
to publish. Some libraries get this wrong and accidentally leak HS256
“public” keys to clients that then treat them as verification material.
Related RFCs ¶
- RFC 7515 JWS — uses JWK for public-key lookup at verification
- RFC 7516 JWE — uses JWK for recipient-key lookup at encryption
- RFC 7518 JWA — defines which key types and parameters are valid
- RFC 7638 — JWK Thumbprint; canonical key fingerprint
- RFC 8414 —
jwks_urimetadata field - RFC 9449 — DPoP
cnf.jktis an RFC 7638 thumbprint