RFC 9396 — OAuth 2.0 Rich Authorization Requests (RAR)
Implemented (core/authorization_details.go + apiauth/ token / introspection / middleware)
Source: docs/oauth/RFC_9396.md
RFC 9396 — OAuth 2.0 Rich Authorization Requests (RAR) ¶
Status: Standards Track
Published: 2023-05
L-tier / T-tier: L6 · T1 (prepare) + T5 (carry through mint) + T7 (verify at RS)
OneAuth coverage: Implemented (core/authorization_details.go+apiauth/token / introspection / middleware)
See also:RFC_9126.md·RFC_9101.md·LANDSCAPE.md
In one sentence ¶
RAR replaces the flat scope string with a structured
authorization_details JSON array — letting the request express exactly
what’s being asked for (e.g., “transfer £500 from account A to merchant B
once”) rather than a coarse “payments” scope.
What problem does it solve? ¶
| Without RAR | With RAR |
|---|---|
scope="payments" means “all payment operations forever” — coarse, dangerous |
authorization_details=[{type:"payment", amount:500, beneficiary:"B"}] is precise and one-shot |
| Banking, healthcare, and regulated APIs invent ad-hoc parameters to carry transaction-specific details | One spec; one place to put structured authorization data |
| Audit trails (what was authorized?) need to parse out vendor-specific extensions | authorization_details is the canonical record |
| Step-up authentication (mid-session, “approve this particular transfer”) needs request-specific data | RAR is the natural carrier — type + per-type schemas |
RAR is the expressivity upgrade for authorization. Scope is “what API
surface”; RAR is “what specific operation, with what parameters.” They’re
complementary — most deployments ship both.
Relatable example ¶
UK Open Banking payment initiation under PSD2 — the canonical RAR use case
that drove the spec:
A third-party payment service provider (PSP) wants to initiate a £500
transfer from a customer’s account at HSBC to merchant ACME. Without RAR,
the authorization is “the PSP can do payment operations” — vague,
dangerous, hard to audit. With RAR, the authorization request says
exactly what’s being asked:
"authorization_details": [{
"type": "payment_initiation",
"actions": ["initiate"],
"instructedAmount": {
"currency": "GBP",
"amount": "500.00"
},
"creditorName": "ACME Corp",
"creditorAccount": {
"iban": "DE89370400440532013000"
}
}]
The customer’s bank shows them the actual transaction details on the
consent screen. The customer approves the specific transfer, not the
PSP’s general access. The issued access token carries the same
authorization_details — the RS verifies the operation matches.
Any future API call from the PSP that tries to do something different (a
different amount, a different beneficiary) is rejected because the token’s
authorization_details don’t match.
Key concepts ¶
authorization_detailsis an array of objects. Each object has
at minimum atypefield naming a type-specific schema. Beyond
type, the schema is defined per type — by the AS, an industry
profile, or a regulator.- Three places the data appears on the wire:
- In the authorization request (T1):
authorization_detailsURL/POST param - In the token response (T5): mirrored back so the client knows what was granted
- In the token claims / introspection response (T7): the RS reads it
- In the authorization request (T1):
- Composes with
scope. Not exclusive — many deployments use scope
for coarse-grained capabilities and RAR for transaction details.
scope=payments authorization_details=[{type:"payment_initiation", ...}]. typevalues are registered. OpenID has definedpayment_initiation,
account_information,customer_information, etc. Industry profiles
(Open Banking, healthcare) add more. AS can advertise the types it
accepts viaauthorization_details_types_supported(RFC 8414).- Cross-spec composition. RAR rides naturally inside PAR (RFC 9126)
and JAR (RFC 9101). The combination — structured authorization
(RAR), back-channel transport (PAR), signed integrity (JAR) — is the
FAPI 2.0 baseline.
Wire example ¶
Authorization request with RAR:
GET /authorize?response_type=code
&client_id=psp-1
&redirect_uri=https%3A%2F%2Fpsp.example%2Fcb
&scope=openid
&state=xyz
&code_challenge=E9Mel...
&code_challenge_method=S256
&authorization_details=%5B%7B%22type%22%3A%22payment_initiation%22%2C%22actions%22%3A%5B%22initiate%22%5D%2C%22instructedAmount%22%3A%7B%22currency%22%3A%22GBP%22%2C%22amount%22%3A%22500.00%22%7D%2C%22creditorName%22%3A%22ACME+Corp%22%7D%5D HTTP/1.1
Host: bank.example
(URL-decoded authorization_details is the JSON shown above.)
Token response carries authorization_details back:
{
"access_token": "eyJhbGciOi...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "openid",
"authorization_details": [{
"type": "payment_initiation",
"actions": ["initiate"],
"instructedAmount": {"currency": "GBP", "amount": "500.00"},
"creditorName": "ACME Corp"
}]
}
Issued access token (JWT) carries it as a claim:
{
"iss": "...", "sub": "...", "aud": "...", "exp": ..., "iat": ...,
"client_id": "psp-1",
"scope": "openid",
"authorization_details": [{
"type": "payment_initiation",
"actions": ["initiate"],
"instructedAmount": {"currency": "GBP", "amount": "500.00"},
"creditorName": "ACME Corp"
}]
}
RS validates the actual operation against the token:
When the PSP calls POST /payments with that token, the RS verifies:
- Token signature + standard JWT validation
authorization_detailsincludes apayment_initiationentry- The actual payment in the request matches
instructedAmount,
creditorName, etc. in the token
Mismatch → reject. The bank issues exactly the authorization that was
asked for.
Where it lands on the OAuth abstraction ¶
- L6 request integrity. Not because RAR adds signatures (it doesn’t),
but because it tightens the contract — what was asked is exactly what
was granted. - T1, T5, T7. RAR data crosses the whole request lifecycle, unlike
PAR/JAR which only touch T1. - AS metadata field:
authorization_details_types_supportedlists
thetypevalues the AS accepts. OneAuth’sASServerMetadataalready
has this.
OAuth 2.0 status ¶
Published 2023. Adopted by Open Banking (UK, EU PSD2, Australia, Brazil),
some healthcare profiles, and emerging in financial APIs more broadly.
Not yet mainstream in consumer OAuth, but the design wins are clear
enough that adoption is growing.
OAuth 2.1 status ¶
Not mandated by 2.1. Optional. The spec is referenced as the right
mechanism for transaction-specific authorization. FAPI 2.0 mandates RAR
for payment-initiation use cases.
When NOT to use it ¶
- Simple capability-based APIs where “user can read their own
profile” is the full authorization story.scope=profileis exactly
right; RAR would be over-engineered. - Internal services without transaction-specific concerns. RAR’s
expressivity is wasted. - Deployments without a clear
typeschema. Inventing custom RAR
types without a profile is hard to maintain. If you don’t have a
regulator or industry profile, you’re probably premature in adopting
RAR.
OneAuth status ¶
| 9396 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
AuthorizationDetail type |
Implemented | core/authorization_details.go AuthorizationDetail struct with Type + Actions + custom marshaler for extensions |
Type-required (§5.2) validated in Validate() |
Validate / ValidateAll |
Implemented | core/authorization_details.go AuthorizationDetail.Validate, ValidateAll |
Returns ErrInvalidAuthorizationDetails per §5.2 |
FilterByType helper |
Implemented | core/authorization_details.go FilterByType |
Useful for RS-side per-type checks |
| Token-endpoint parsing | Implemented | apiauth/token_endpoint.go parses the JSON-encoded form param per §6.1; the grant handlers validate via core.ValidateAll |
Malformed JSON is 400 invalid_authorization_details |
| Per-grant validation | Implemented | TokenEndpointHandler.handlePassword and handleClientCredentials in apiauth/token_endpoint.go; jwtBearerGranter.JwtBearerGrant; tokenExchanger.TokenExchange |
Each runs core.ValidateAll on request-supplied details and answers 400 invalid_authorization_details. A malformed value on the password grant was a 500 before 0.1.48. The authorization-code grant issues the details stored with the code (AuthorizationCodeGranter); /authorize does not parse authorization_details |
| Registered types enforced at the token endpoint | Implemented | checkRARTypes and clientRegistration in apiauth/client_policy.go; TestTokenInput_RARTypesHonorTheRegistration |
Since 0.1.48, with an AppStore, client_credentials and the password grant answer 400 invalid_authorization_details for a type outside the client’s registered authorization_details_types. A registration listing no types allows any type. A store error other than not-found fails closed as server_error |
| Refresh-token carry forward | Implemented | apiauth/token_validator.go jwtIssuer.RefreshGrant reissues rt.AuthorizationDetails |
RAR survives refresh per §10 |
Token response includes authorization_details |
Implemented | apiauth/token_endpoint.go TokenEndpointHandler.writeTokens encodes core.TokenPair.AuthorizationDetails, called from all handlers |
— |
| JWT claim emission | Implemented | apiauth/token_validator.go jwtIssuer.CreateAccessToken sets claims["authorization_details"] = details (and jwtIDJAGIssuer.CreateIDJAG in apiauth/id_jag.go) |
Carried into issued JWTs |
Middleware extraction (GetAuthorizationDetailsFromContext) |
Implemented | apiauth/middleware.go GetAuthorizationDetailsFromContext accessor; APIMiddleware.validateJWTInline parses the claim (parseAuthorizationDetailsFromClaims in apiauth/rar_claims.go) into context |
RS-side accessor |
Introspection response includes authorization_details |
Implemented | apiauth/introspection.go; TestIntrospection_WithRAR in apiauth/auth_rar_test.go |
— |
AS metadata advertisement (authorization_details_types_supported) |
Implemented | ASServerMetadata.AuthorizationDetailsTypesSupported in apiauth/as_metadata.go |
Deployment-configurable |
DCR client metadata (authorization_details_types) |
Implemented | DCRRequest.AuthorizationDetailsTypes in admin/dcr.go |
Per-client declared types. The token endpoint enforces them since 0.1.48 (row above) |
OneAuth’s RAR implementation is one of the most comprehensive RFC
coverages in the codebase — it spans token endpoint, refresh, JWT
emission, introspection, middleware extraction, AS metadata, and DCR.
This is the model “implemented across the surface” RFC.
Related RFCs ¶
- RFC 6749 — the framework whose
scopemechanism RAR complements - RFC 9126 — PAR; the natural transport for verbose
authorization_details - RFC 9101 — JAR; signs RAR-bearing requests
- RFC 7662 — Introspection; returns
authorization_details - RFC 9068 — JWT AT profile;
authorization_detailsis a recognized claim - RFC 8414 —
authorization_details_types_supportedmetadata - FAPI 2.0 — uses RAR for payment-initiation
- Open Banking — defined the
payment_initiationtype
Spec links ¶
- Datatracker: rfc9396
- RFC editor copy
- Errata search
- OpenID authorization_details type registry (informal, evolving)