RFC 7523 — JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants
Grant: Implemented. Client auth: Implemented (client_secret_jwt PR 293; private_key_jwt shipped)
Source: docs/oauth/RFC_7523.md
RFC 7523 — JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants ¶
Status: Standards Track
Published: 2015-05
L-tier / T-tier: L4 (jwt-bearer grant) + L5 (private_key_jwt / client_secret_jwt client auth) · T5
OneAuth coverage: Grant: Implemented. Client auth: Implemented (client_secret_jwtPR 293;private_key_jwtshipped)
See also:RFC_7521.md·RFC_8693.md·LANDSCAPE.md
In one sentence ¶
RFC 7523 is the JWT-specific binding of the 7521 assertion framework —
it lets a signed JWT serve as either (a) the grant that authorizes a token
mint, or (b) the client’s credentials at /token. Same wire shape, two
purposes.
What problem does it solve? ¶
| Without 7523 | With 7523 |
|---|---|
client_secret_basic leaks a shared secret on every request; client_secret_post is no better |
Asymmetric (private_key_jwt) or HMAC-keyed (client_secret_jwt) signed assertion — proof of possession, no secret on wire |
| Service-to-service trust requires shared credentials in every direction | One service signs a JWT with its private key; the other verifies via JWKS — no shared state |
| Cross-org federation needs custom token-exchange protocols | “Here’s a JWT signed by my issuer” is the universal handoff |
7523 is two specs in one document, and the dual-use is on purpose. The
client authentication mode replaces leaky shared secrets; the grant
mode enables federated delegation.
Relatable example ¶
Mode A — client authentication (private_key_jwt). Your backend service
authenticates to a partner API:
- At setup time, your service registers a public key with the partner AS.
- For every
/tokencall, your service constructs and signs a fresh JWT:
{iss: "your-client-id", sub: "your-client-id", aud: "https://partner/token", exp: now+60, jti: uuid},
signed with your private key. - POSTs it as
client_assertion. Partner verifies via your published
public key.
No shared secret. Stolen-secret class of attacks eliminated. This is what
private_key_jwt does.
Mode B — JWT-bearer grant. GitHub Actions deploys to AWS:
- GitHub issues a signed OIDC token to the CI job:
{iss: "https://token.actions.githubusercontent.com", sub: "repo:org/repo:ref:main", aud: "sts.amazonaws.com", ...}. - The CI job presents this JWT as
assertion=<jwt>with
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearerto AWS. - AWS validates against GitHub’s JWKS, applies its trust policy, returns
AWS-format credentials.
(In practice AWS uses its own STS API shape that predates RFC 7523, but the
semantic is exactly the grant mode of 7523.)
Key concepts ¶
- Two modes, one spec:
- Grant mode (§2.1):
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer,
assertion=<JWT>. The JWT is the authorization. - Client auth mode (§2.2):
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer,
client_assertion=<JWT>. The JWT is the client credential.
- Grant mode (§2.1):
- Required JWT claims:
iss,sub,aud,exp. For client auth,
iss == sub == client_id; for grant mode,issis the trusted issuer
andsubis the subject identity being delegated. audmust include the AS’s token endpoint URL. Prevents
cross-AS replay.- Short-lived;
jtifor one-time use. RFC 7523 recommends “as short
as possible” lifetimes — typically 30–300 seconds.jtienables the AS
to detect replay. - Symmetric vs asymmetric: 7523 covers both —
private_key_jwt
(RSA/ECDSA, public key published; preferred) andclient_secret_jwt
(HMAC-SHA256, key is the client_secret).
Wire example ¶
Client authentication via private_key_jwt:
POST /api/token HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&scope=read
&client_id=my-service-account
&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
&client_assertion=eyJhbGciOiJSUzI1NiIsImtpZCI6Im15LWtleS0xIn0.eyJpc3MiOiJteS1zZXJ2aWNlLWFjY291bnQiLCJzdWIiOiJteS1zZXJ2aWNlLWFjY291bnQiLCJhdWQiOiJodHRwczovL2FzLmV4YW1wbGUuY29tL2FwaS90b2tlbiIsImV4cCI6MTcxNzAwMDA2MCwiaWF0IjoxNzE3MDAwMDAwLCJqdGkiOiJjbGllbnQtYXNzZXJ0aW9uLWFiYzEifQ.signature_bytes
Decoded client_assertion:
{ "iss":"my-service-account", "sub":"my-service-account",
"aud":"https://as.example.com/api/token",
"exp":1717000060, "iat":1717000000, "jti":"client-assertion-abc1" }
AS validates: signature against published JWK for my-service-account,
iss == sub == client_id, aud matches token endpoint, exp future,
jti not seen before.
JWT-bearer grant:
POST /api/token HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
&assertion=<github-issued-OIDC-token>
&scope=deploy
AS validates the OIDC token (via the trusted issuer’s JWKS), applies its
policy (“does sub=repo:org/repo allow scope=deploy?”), mints an access
token.
Where it lands on the OAuth abstraction ¶
- L4 grant + L5 client auth. Same RFC fills two slots.
- T5 (token endpoint). Both modes act at
/token. - 7523 is the concrete binding of RFC 7521’s framework.
OAuth 2.0 status ¶
Part of the 2.0 ecosystem from 2015. The dominant non-shared-secret client
authentication today. JWT-bearer grant is the basis for nearly every
modern federation flow.
OAuth 2.1 status ¶
Not changed by 2.1. The two modes carry through unchanged.
Migration path (shared-secret → assertion-based client auth) ¶
Most production deployments still use client_secret_basic for confidential
clients. Migration to private_key_jwt:
- Generate an asymmetric key pair per client. Publish the public key
in the client’sjwks(orjwks_uri) metadata via DCR (RFC 7591). - Client constructs a fresh
client_assertionJWT per token call.
Library support is universal (golang-jwt, jose-jwt, jsonwebtoken). - AS validates — OneAuth does this via
ClientAuthenticator.AuthenticateClient(clientAuthenticator.authenticateAssertioninapiauth/client_authenticator.go). - Remove the
client_secretfrom the client’s registration once all
token calls use private_key_jwt. Defense-in-depth — without a secret to
leak, there’s no secret-leak attack.
The asymmetric variant (private_key_jwt) is the long-term recommendation.
The symmetric (client_secret_jwt) is a transition path for deployments
that can’t yet manage asymmetric keys per client.
OneAuth status ¶
| 7523 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
grant_type=...:jwt-bearer (grant mode) |
Implemented | apiauth/token_endpoint.go case JwtBearerGrantType → TokenEndpointHandler.dispatchJwtBearer; full handler at apiauth/jwt_bearer_granter.go jwtBearerGranter.JwtBearerGrant (RFC 7523 §2.1) |
Multiple test cases in jwt_bearer_grant_test.go |
urn:ietf:params:oauth:grant-type:jwt-bearer constant |
Implemented | apiauth/jwt_bearer_grant.go JwtBearerGrantType |
— |
client_assertion_type=...:jwt-bearer (client auth) |
Implemented | apiauth/client_authenticator.go checks the exact ClientAssertionTypeJWTBearer URN |
— |
private_key_jwt (asymmetric) |
Implemented | apiauth/client_authenticator.go authenticateAssertion validates JWS signature against published JWK |
Method field returns "private_key_jwt" for asymmetric clients |
Keys from the client’s jwks_uri |
Implemented | apiauth/client_authenticator.go jwksAssertionKey; apiauth/client_jwks.go |
The key is picked by kid, with one rate-limited refetch on an unknown kid so a client can rotate keys. The algorithm is the header’s only if the key’s type can verify it, and only the registered token_endpoint_auth_signing_alg when the client set one (issue 507) |
client_secret_jwt (HMAC) |
Implemented | apiauth/client_authenticator.go authenticateAssertion + TestClientSecretJWT_MethodClassification in apiauth/client_secret_jwt_test.go validates Method == "client_secret_jwt" |
Landed in PR 293 (issue 159) |
iss == sub == client_id enforcement (§3) |
Implemented | apiauth/client_authenticator.go validates per §3 |
— |
aud matches AS token endpoint |
Implemented | apiauth/client_authenticator.go against AcceptedAudiences; fallback derivedAudience in apiauth/client_credentials.go |
Prevents cross-AS replay. Since 0.1.52 the derived audience never reads X-Forwarded-Host, which had let a caller choose the audience its own assertion was checked against. Its scheme is https when r.TLS is set or when a peer in OneAuthConfig.TrustedProxies sends X-Forwarded-Proto: https (issue 541); from any other peer that header is ignored. The token endpoint also accepts the issuer (§3). Behind a TLS proxy set OneAuthConfig.AcceptedAudiences; the reference server sets it from jwt.issuer and public_url. Under OneAuthConfig.FAPI2 the issuer is the only accepted audience and aud must be a single string |
exp short-lived enforcement |
Implemented | Library default + explicit window; ValidateAssertion in apiauth/jwt_bearer_grant.go |
Since 0.1.45 a jwt-bearer grant assertion must carry exp and is checked against a configured audience (TrustedAssertionIssuer.Audiences, else the AS audience or issuer URL). With none configured every assertion is refused |
jti replay defense |
Implemented | apiauth/client_authenticator.go calls jtiStore.SeenWithin(jti, replayWindow) and rejects on hit; pluggable JTIStore interface for distributed deployments. For the grant, jwtBearerGranter.JwtBearerGrant spends any assertion that carries a jti, keyed by iss + jti (0.1.45) |
Tested in TestClientSecretJWT_RejectsReplayedJTI, TestPrivateKeyJWT_RejectsReplayedJTI and TestJwtBearerHardening_AssertionWithJTIIsSingleUse |
AS metadata advertisement (token_endpoint_auth_signing_alg_values_supported) |
Implemented | ASServerMetadata.TokenEndpointAuthSigningAlgValuesSupported in apiauth/as_metadata.go; see RFC 8414 doc |
— |
| Assertion algorithms under FAPI 2.0 | Implemented | AuthenticateClientRequest.AllowedAssertionAlgs; fapi2AssertionAlgs in apiauth/fapi2.go |
Since 0.1.54 FAPI2 accepts only PS256, ES256 and EdDSA client assertions. Inline registered keys can only be ES256 of those (#330, #331), so an RS256 private_key_jwt client stops authenticating when FAPI is on. A jwks_uri client can use PS256, ES256 or EdDSA (issue 507) |
| ID-JAG redemption (MCP EMA) | Implemented | apiauth/jwt_bearer_granter.go — detects typ=oauth-id-jag+jwt, enforces single-use jti, binds client_id onto the access token; e2e in client/enterprise_managed_e2e_test.go |
An ID-JAG is a trusted-issuer JWT, so the §2.1 grant redeems it directly |
| Confidential-client auth (§3, optional) | Implemented | apiauth/confidential_client_auth.go + jwt_bearer_granter.go; tests in confidential_client_grants_test.go |
Issue 356. Registered confidential client (auth method != none) MUST authenticate; unregistered/public stays assertion-only. An unknown client_id takes the public path, since §3 makes client auth optional here (device_code fails closed). An AppStore error other than not-found is a 500 since 0.1.41, where it used to read as a public client. Under FAPI2 an unregistered or public client is refused with invalid_client (0.1.52) |
| Auth-method binding (no downgrade) | Implemented | apiauth/client_authenticator.go enforceAuthMethodBinding / authMethodFamilyMatches; tests in client_auth_method_binding_test.go |
Issue 360. When an AppStore is wired, the presented method MUST match the registered token_endpoint_auth_method family — a private_key_jwt client cannot fall back to a shared secret, and the reverse. client_secret_basic/_post are one family; assertion methods bind exactly. Applies to every grant that authenticates a client, not just jwt-bearer |
The client_secret_jwt + private_key_jwt pair gives OneAuth one of the
strongest L5 client auth postures in the OAuth library landscape, well
ahead of bare-secret deployments. Auth-method binding (issue 360) closes the
last downgrade path: a client cannot authenticate with a weaker method than the
one it registered.
ID-JAG redemption hardening (MCP Enterprise-Managed Authorization) ¶
When the presented assertion is an ID-JAG (JWS typ == oauth-id-jag+jwt),
the jwt-bearer grant applies EMA-specific hardening on top of plain §2.1:
- Single-use. The ID-JAG
jtiis recorded in aJTIStore(the same
replay interface used for client-assertion defense); a replayed ID-JAG is
rejected withinvalid_grant. In-memory by default; swap in a distributed
store viaJwtBearerGranterConfig.ReplayStore/OneAuthConfig.IDJAGReplayStore. - Audience binding. The ID-JAG
aud(the resource app’s AS) is checked
against this AS via the standard §3 audience validation. - client_id binding. The issued MCP access token carries the ID-JAG’s
client_idclaim (draft §5), so the resource server sees which client the
IdP vouched for.
Plain jwt-bearer assertions (no ID-JAG typ) get no client_id binding. Since 0.1.45 any assertion that carries a jti is single-use too, keyed by iss and jti, since jti values are unique only per issuer. Issuance is the
sibling RFC 8693 token-exchange path. act/actor propagation
for agent-vs-user identity is a tracked follow-up (mcpkit ext-auth#13).
When NOT to use it ¶
- Tiny prototypes / dev —
client_secret_basicis operationally
simpler. Don’t over-engineer. - Strictly internal deployments with controlled networks — the
marginal security benefit may not justify the JWT-construction overhead. - Public clients (no secret) — assertion auth doesn’t apply; use
PKCE instead.
Related RFCs ¶
- RFC 7521 — the assertion framework 7523 binds
- RFC 7522 — SAML 2.0 binding (niche)
- RFC 6749 — the framework whose grant + client-auth slots 7523 fills
- RFC 7519 — JWT structure
- RFC 7515 — JWS signing the assertion
- RFC 7517 — JWKS where verifiers find the public key
- RFC 8693 — Token Exchange; sibling delegation primitive