RFC 9396: OAuth 2.0 Rich Authorization Requests
- T. Lodderstedt,
- J. Richer,
- B. Campbell
Abstract
This document specifies a new parameter authorization that is
used to carry fine-grained authorization data in OAuth messages.¶
Status of This Memo
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any
errata, and how to provide feedback on it may be obtained at
https://
Copyright Notice
Copyright (c) 2023 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://
1. Introduction
"The OAuth 2.0 Authorization Framework" [RFC6749] defines the scope parameter that allows OAuth clients to
specify the requested scope, i.e., the limited capability, of an access token.
This mechanism is sufficient to implement static scenarios and
coarse-grained authorization requests, such as "give me read access to
the resource owner's profile." However, it is not sufficient to specify
fine-grained authorization requirements, such as "please let me transfer an amount of 45 Euros to Merchant A"
or "please give me read access to directory A and write access to file X."¶
This specification introduces a new parameter authorization that allows clients to specify their fine-grained authorization requirements using the expressiveness of JSON [RFC8259] data structures.¶
For example, an authorization request for a credit transfer (designated as "payment initiation" in several open banking initiatives) can be represented using a JSON object like this:¶
This object contains detailed information about the intended payment, such as amount, currency, and creditor, that is required to inform the user and obtain their consent. The authorization server (AS) and the respective resource server (RS) (providing the payment initiation API) will together enforce this consent.¶
For a comprehensive discussion of the challenges arising from new use cases in the open banking and electronic signing spaces, see [Transaction-Auth].¶
In addition to facilitating custom authorization requests, this specification also introduces a set of common data type fields for use across different APIs.¶
1.1. Conventions and Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
This specification uses the terms "access token", "refresh token", "authorization server" (AS), "resource server" (RS), "authorization endpoint", "authorization request", "authorization response", "token endpoint", "grant type", "access token request", "access token response", and "client" defined by "The OAuth 2.0 Authorization Framework" [RFC6749].¶
2. Request Parameter "authorization_details"
The request parameter authorization contains, in JSON notation, an array of objects. Each JSON object contains the data to specify the authorization requirements for a certain type of resource. The type of resource or access requirement is determined by the type field, which is defined as follows:¶
-
type: - An identifier for the authorization details type as a string. The value of the
typefield determines the allowable contents of the object that contains it. The value is unique for the described API in the context of the AS. This field is REQUIRED.¶
An authorization array MAY contain multiple entries of the same type.¶
Figure 2 shows an authorization of type payment using the example data shown above:¶
Figure 3 shows a combined request asking for access to account information and permission to initiate a payment:¶
The JSON objects with type fields of account and payment represent the different authorization to be used by the AS to ask for consent.¶
2.2. Common Data Fields
This specification defines a set of common data fields that are designed to be usable across different types of APIs. This specification does not require the use of these common fields by an API definition but, instead, provides them as reusable generic components for API designers to make use of. The allowable values of all fields are determined by the API being protected, as defined by a particular "type" value.¶
-
locations: - An array of strings representing the location of the resource or RS. These strings are typically URIs identifying the location of the RS. This field can allow a client to specify a particular RS, as discussed in Section 12.¶
-
actions: - An array of strings representing the kinds of actions to be taken at the resource.¶
-
datatypes: - An array of strings representing the kinds of data being requested from the resource.¶
-
identifier: - A string identifier indicating a specific resource available at the API.¶
-
privileges: - An array of strings representing the types or levels of privilege being requested at the resource.¶
When different common data fields are used in combination, the permissions the client requests are the product of all the values.
The object represents a request for all actions values listed within the object
to be used at all locations values listed within the object for all datatypes
values listed within the object. In the following example, the client is requesting read and write
access to both the contacts and photos belonging to customers in a customer API.
If this request is granted, the client
would assume it would be able to use any combination of rights
defined by the API, such as read access to the photos and write
access to the contacts.¶
If the client wishes to have finer control over its access, it can send multiple objects. In this example,
the client is asking for read access to the contacts and write access to the photos in the same API endpoint.
If this request is granted, the client would not be able to write to the contacts.¶
An API MAY define its own extensions, subject to the type of the respective authorization object.
It is anticipated that API designers will use a combination
of common data fields defined in this specification as well as
fields specific to the API itself. The following non-normative
example shows the use of both common and API-specific fields as
part of two different fictitious API type values. The first
access request includes the actions, locations, and datatypes
fields specified here as well as the API-specific geolocation
field, indicating access to photos taken at the given coordinates.
The second access request includes the actions and
identifier fields specified here as well as the API-specific
currency fields.¶
If this request is approved, the resulting access token's access rights will be the union of the requested types of access for each of the two APIs, just as above.¶
3. Authorization Request
The authorization authorization request parameter can be used to specify authorization requirements in all places where the scope parameter is used for the same purpose, examples include:¶
In case of authorization requests as defined in [RFC6749], implementers MAY consider using pushed authorization requests [RFC9126] to improve the security, privacy, and reliability of the flow. See Sections 12, 13, and 11.4 for details.¶
Parameter encoding is determined by the respective context. In the context of an authorization request according to [RFC6749], the parameter is encoded using the application format of the serialized JSON as shown in Figure 8, using the example from Section 2 (line breaks for display purposes only):¶
Based on the data provided in the authorization parameter, the AS will ask the user for consent to the requested access permissions.¶
In Figure 9, the client wants to get access to account information and initiate a payment:¶
3.1. Relationship to the "scope" Parameter
authorization and scope can be used in the same authorization request for carrying independent authorization requirements.¶
Combined use of authorization and scope is supported by this specification in part to allow existing OAuth-based applications to incrementally migrate towards using authorization exclusively. It is RECOMMENDED that a given API use only one form of requirement specification.¶
The AS MUST process both sets of requirements in combination with each other for the given authorization request. The details of how the AS combines these parameters are specific to the APIs being protected and outside the scope of this specification.¶
When gathering user consent, the AS MUST present the merged set of requirements represented by the authorization request.¶
If the resource owner grants the client the requested access, the AS will issue tokens to the client that are associated with the respective authorization (and scope values, if applicable).¶
3.2. Relationship to the "resource" Parameter
The resource authorization request parameter, as defined in [RFC8707], can be used to further determine the resources where the requested scope can be applied. The resource parameter does not have any impact on the way the AS processes the authorization authorization request parameter.¶
5. Authorization Error Response
The AS MUST refuse to process any unknown authorization details type or authorization details not conforming to the respective type definition. The AS MUST abort processing and respond with an error invalid to the client if any of the following are true of the objects in the authorization structure:¶
6. Token Request
The authorization token request parameter can be used to specify the authorization details that a client wants the AS to assign to an access token. The AS checks whether the underlying grant (in case of grant types authorization, refresh_token, etc.) or the client's policy (in case of grant type client) allows the issuance of an access token with the requested authorization details. Otherwise, the AS refuses the request with the error code invalid (similar to invalid_scope).¶
7. Token Response
In addition to the token response parameters as defined in [RFC6749], the AS MUST also return the authorization as granted by the resource owner and assigned to the respective access token.¶
The authorization details assigned to the access token issued in a token response are determined by the authorization parameter of the corresponding token request. If the client does not specify the authorization token request parameters, the AS determines the resulting authorization at its discretion.¶
The AS MAY omit values in the authorization to the client.¶
For our running example, it would look like this:¶
8. Token Error Response
The Token Error Response MUST conform to the rules given in Section 5.¶
9. Resource Servers
In order to enable the RS to enforce the authorization details as approved in the authorization process, the AS MUST make this data available to the RS. The AS MAY add the authorization field to access tokens in JSON Web Token (JWT) format or to token introspection responses.¶
9.1. JWT-Based Access Tokens
If the access token is a JWT [RFC7519], the AS is RECOMMENDED to add the authorization details object, filtered to the specific audience, as a top-level claim.¶
The AS will typically also add further claims to the JWT that the RS requires request processing, e.g., user ID, roles, and transaction
The following shows the contents of an example JWT for the payment initiation example above:¶
In this case, the AS added the following example claims to the JWT-based access token:¶
-
sub: - indicates the user for which the client is asking for payment initiation.¶
-
txn: - transaction id used to trace the transaction across the services of provider
example.com¶ -
debtorAccount: - API-specific field containing the debtor account. In the example, this account was not passed in the
authorizationbut was selected by the user during the authorization process. The field_details user_roleconveys the role the user has with respect to this particular account. In this case, they are the owner. This data is used for access control at the payment API (the RS).¶
9.2. Token Introspection
Token introspection [RFC7662] provides a means for an RS to query the AS to determine information about an access token. If the AS includes authorization detail information for the token in its response, the information MUST be conveyed with authorization as a top-level member of the introspection response JSON object. The authorization member MUST contain the same structure defined in Section 2, potentially filtered and extended for the RS making the introspection request.¶
Here is an example introspection response for the payment initiation example:¶
10. Metadata
To advertise its support for this feature, the supported list of authorization details types is included in the AS metadata response [RFC8414] using the metadata parameter authorization, which is a JSON array.¶
This is illustrated by the following example:¶
Clients MAY indicate the authorization details types they will use when requesting authorization with the client registration metadata parameter authorization, which is a JSON array.¶
This is illustrated by the following example:¶
The registration of authorization details types with the AS is outside the scope of this specification.¶
11. Implementation Considerations
11.2. Minimal Implementation Support
General AS implementations supporting this specification should provide the following basic functions:¶
Processing and presentation of authorization details will vary significantly among different authorization details types. Implementations should therefore support customization of the respective behavior. In particular, implementations should allow deployments to:¶
One approach to supporting such customization would be to have a mechanism allowing the registration of extension modules, each of them responsible for rendering the respective user consent and any transformation needed to provide the data needed to the RS by way of structured access tokens or token introspection responses.¶
11.3. Use of Machine-Readable Type Schemas
Implementations might allow deployments to use machinetype were defined using JSON Schemas [JSON.Schema], the JSON Schema identifier could be used as type value in the respective authorization details objects.¶
Note, however, that type values are identifiers understood by the AS and, to the extent necessary, the client and RS.
This specification makes no assumption that a type value would point to a machinetype field in any specific way.¶
11.4. Large Requests
Authorization request URIs containing authorization in a request parameter or a request object can become very long. Therefore, implementers should consider using the request_uri parameter as defined in [RFC9101] in combination with the pushed request object mechanism as defined in [RFC9126] to pass authorization in a reliable and secure manner. Here is an example of such a pushed authorization request that sends the authorization request data directly to the AS via an HTTPS-protected connection:¶
12. Security Considerations
The authorization parameter is sent through the user agent in case of an OAuth authorization request, which makes them vulnerable to modifications by the user. If the integrity of the
authorization is a concern, clients MUST protect authorization against tampering and swapping. This can be achieved by signing the request using signed request objects as defined in [RFC9101] or using the request_uri authorization request parameter as defined in [RFC9101] in conjunction with [RFC9126] to pass the URI of the request object to the AS.¶
All string comparisons in an authorization parameter are to be done as defined by [RFC8259]. No additional transformation or normalization is to be done in evaluating equivalence of string values.¶
The common data field locations allows a client to specify where it intends to use a certain authorization, i.e., it is possible to unambiguously assign permissions to RSs. In situations with multiple RSs, this prevents unintended client authorizations (e.g., a read scope value potentially applicable for an email as well as a cloud service) through audience restriction.¶
The AS MUST properly sanitize and handle the data passed in the authorization in order to prevent injection attacks.¶
The Security Considerations of [RFC6749], [RFC7662], and [RFC8414] also apply.¶
13. Privacy Considerations
It is especially important for implementers to design and use authorization details in a privacy
Any sensitive personal data included in authorization must be prevented from leaking, e.g., through referrer headers. Implementation options include encrypted request objects as defined in [RFC9101] or transmission of authorization via end-to-end encrypted connections between client and AS by utilizing [RFC9126] and the request_uri authorization request parameter as defined in [RFC9101]. The latter does not require application
Even if the request data is encrypted, an attacker could use the AS to learn the user's data by injecting the encrypted request data into an authorization request on a device under their control and use the AS's user consent screens to show the (decrypted) user data in the clear. Implementations need to consider this attack vector and implement appropriate countermeasures
The AS needs to take into consideration the privacy implications when sharing authorization with the client or RSs. The AS should share this data with those parties on a "need to know" basis as determined by local policy.¶
14. IANA Considerations
14.1. OAuth Parameters Registration
The following parameter has been registered
in the "OAuth Parameters" registry [IANA
14.2. JSON Web Token Claims Registration
The following value has been registered in the IANA "JSON Web Token Claims" registry established by [RFC7519].¶
- Claim Name:
-
authorization¶_details - Claim Description:
- The claim
authorizationcontains a JSON array of JSON objects representing the rights of the access token. Each JSON object contains the data to specify the authorization requirements for a certain type of resource.¶_details - Change Controller:
- IETF¶
- Reference:
- Section 9.1 of RFC 9396¶
14.3. OAuth Token Introspection Response Registration
The following value has been registered in the IANA "OAuth Token Introspection Response" registry established by [RFC7662].¶
- Name:
-
authorization¶_details - Description:
- The member
authorizationcontains a JSON array of JSON objects representing the rights of the access token. Each JSON object contains the data to specify the authorization requirements for a certain type of resource.¶_details - Change Controller:
- IETF¶
- Reference:
- Section 9.2 of RFC 9396¶
14.5. OAuth Dynamic Client Registration Metadata Registration
The following value has been registered in the IANA "OAuth Dynamic Client Registration Metadata" registry of [IANA
- Client Metadata Name:
-
authorization¶_details _types - Client Metadata Description:
- Indicates what authorization details types the client uses.¶
- Change Controller:
- IETF¶
- Reference:
- Section 10 of RFC 9396¶
14.6. OAuth Extensions Error Registration
The following value has been registered in the IANA "OAuth Extensions Error Registry" of [IANA
15. References
15.1. Normative References
- [RFC2119]
-
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10
.17487 , , <https:///RFC2119 www >..rfc -editor .org /info /rfc2119 - [RFC7519]
-
Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token (JWT)", RFC 7519, DOI 10
.17487 , , <https:///RFC7519 www >..rfc -editor .org /info /rfc7519 - [RFC7662]
-
Richer, J., Ed., "OAuth 2.0 Token Introspection", RFC 7662, DOI 10
.17487 , , <https:///RFC7662 www >..rfc -editor .org /info /rfc7662 - [RFC8174]
-
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10
.17487 , , <https:///RFC8174 www >..rfc -editor .org /info /rfc8174 - [RFC8414]
-
Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0 Authorization Server Metadata", RFC 8414, DOI 10
.17487 , , <https:///RFC8414 www >..rfc -editor .org /info /rfc8414 - [RFC8628]
-
Denniss, W., Bradley, J., Jones, M., and H. Tschofenig, "OAuth 2.0 Device Authorization Grant", RFC 8628, DOI 10
.17487 , , <https:///RFC8628 www >..rfc -editor .org /info /rfc8628 - [RFC8707]
-
Campbell, B., Bradley, J., and H. Tschofenig, "Resource Indicators for OAuth 2.0", RFC 8707, DOI 10
.17487 , , <https:///RFC8707 www >..rfc -editor .org /info /rfc8707
15.2. Informative References
- [CSC]
-
Cloud Signature Consortium, "Architectures and protocols for remote signature applications", Version 1.0.4.0, , <https://
cloudsignatureco >.nsortium .org /wp -content /uploads /2020 /01 /CSC _API _V1 _1 .0 .4 .0 .pdf - [ETSI]
-
ETSI, "Electronic Signatures and Infrastructures (ESI); Protocols for remote digital signature creation", V1.1.1, ETSI TS 119 432, , <https://
www >..etsi .org /deliver /etsi _ts /119400 _119499 /119432 /01 .01 .01 _60 /ts _119432v010101p .pdf - [IANA
.OAuth .Parameters] -
IANA, "OAuth Parameters", <https://
www >..iana .org /assignments /oauth -parameters - [JSON.Schema]
-
OpenJS Foundation, "JSON Schema", <https://
json >.-schema .org / - [OID-CIBA]
-
Fernandez, G., Walter, F., Nennker, A., Tonge, D., and B. Campbell, "OpenID Connect Client
-Initiated Backchannel Authentication Flow - Core 1.0" , , <https://openid >..net /specs /openid -client -initiated -backchannel -authentication -core -1 _0 .html - [OIDC]
-
Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., and C. Mortimore, "OpenID Connect Core 1.0 incorporating errata set 1", , <https://
openid >..net /specs /openid -connect -core -1 _0 .html - [RFC0020]
-
Cerf, V., "ASCII format for network interchange", STD 80, RFC 20, DOI 10
.17487 , , <https:///RFC0020 www >..rfc -editor .org /info /rfc20 - [RFC6749]
-
Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", RFC 6749, DOI 10
.17487 , , <https:///RFC6749 www >..rfc -editor .org /info /rfc6749 - [RFC7591]
-
Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol", RFC 7591, DOI 10
.17487 , , <https:///RFC7591 www >..rfc -editor .org /info /rfc7591 - [RFC8259]
-
Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10
.17487 , , <https:///RFC8259 www >..rfc -editor .org /info /rfc8259 - [RFC9101]
-
Sakimura, N., Bradley, J., and M. Jones, "The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR)", RFC 9101, DOI 10
.17487 , , <https:///RFC9101 www >..rfc -editor .org /info /rfc9101 - [RFC9126]
-
Lodderstedt, T., Campbell, B., Sakimura, N., Tonge, D., and F. Skokan, "OAuth 2.0 Pushed Authorization Requests", RFC 9126, DOI 10
.17487 , , <https:///RFC9126 www >..rfc -editor .org /info /rfc9126 - [Transaction
-Auth] -
Lodderstedt, T., "Transaction Authorization or why we need to re-think OAuth scopes", , <https://
medium >..com /oauth -2 /transaction -authorization -or -why -we -need -to -re -think -oauth -scopes -2326e2038948
Appendix A. Additional Examples
A.1. OpenID Connect
OpenID Connect [OIDC] specifies the JSON-based claims request parameter that can be used to specify the claims a client (acting as an OpenID Connect Relying Party) wishes to receive in a fine-grained and privacy
The combination of the scope value openid and the additional parameter claims can be used beside authorization in the same way as every non-OIDC scope value.¶
Alternatively, there could be an authorization details type for OpenID Connect. This section gives an example of what such an authorization details type could look like, but defining this authorization details type is outside the scope of this specification.¶
These hypothetical examples try to encapsulate all details specific to the OpenID Connect part of an authorization process into an authorization JSON object.¶
The top-level fields are based on the definitions given in [OIDC]:¶
-
claim_sets: - the names of predefined claim sets, replacement for respective scope values, such as
profile¶ -
max_age: - Maximum Authentication Age¶
-
acr_values: - requested Authentication Context Class Reference (ACR) values¶
-
claims: - the
claimsJSON structure as defined in [OIDC]¶
This is a simple request for some claim sets.¶
A.2. Remote Electronic Signing
The following example is based on the concept laid out for remote electronic signing in ETSI TS 119 432 [ETSI] and the Cloud Signature Consortium (CSC) API for remote signature creation [CSC].¶
The top-level fields have the following meaning:¶
-
credentialID: - identifier of the certificate to be used for signing¶
-
documentDigests: - array containing the hash of every document to be signed (
hashfields). Additionally, the correspondinglabelfield identifies the respective document to the user, e.g., to be used in user consent.¶ -
hashAlgorithm: - algorithm that was used to calculate the hash values¶
The AS is supposed to ask the user for consent for the creation of signatures for the documents listed in the structure. The client uses the access token issued as a result of the process to call the document signature API at the respective signing service to actually create the signature. This access token is bound to the client, the user ID and the hashes (and signature algorithm) as consented by the user.¶
A.3. Access to Tax Data
This example is inspired by an API allowing third parties to access citizen's tax declarations and income statements, for example, to determine their creditworthines
The top-level fields have the following meaning:¶
A.4. eHealth
These two examples are inspired by requirements for APIs used in the Norwegian eHealth system.¶
In this use case, the physical therapist sits in front of their computer using a local Electronic Health Records (EHR) system. They want to look at the electronic patient records of a certain patient, and they also want to fetch the patient's journal entries in another system, perhaps at another institution or a national service. Access to this data is provided by an API.¶
The information necessary to authorize the request at the API is only known by the EHR system and must be presented to the API.¶
In the first example, the authorization details object contains the identifier of an organization. In this case, the API needs to know if the given organization has the lawful basis for processing personal health information to give access to sensitive data.¶
In the second example, the API requires more information to authorize the request. In this case, the authorization details object contains additional information about the health institution and the current profession the user has at the time of the request. The additional level of detail could be used for both authorization and data minimization.¶
Description of the fields:¶
-
patient:_identifier - the identifier of the patient composed of a system identifier in OID format (namespace) and the actual value within this namespace.¶
-
reason:_for _request - the reason why the user wants to access a certain API.¶
-
requesting:_entity - specification of the requester by means of identity, role and organizational context. This data is provided to facilitate authorization and for auditing purposes.¶
In this use case, the AS authenticates the requester, who is not the patient, and approves access based on policies.¶
Acknowledgements
We would like to thank Daniel Fett, Sebastian Ebling, Dave Tonge, Mike Jones, Nat Sakimura, and Rob Otto for their valuable feedback during the preparation of this specification.¶
We would also like to thank Vladimir Dzhuvinov, Takahiko Kawasaki, Daniel Fett, Dave Tonge, Travis Spencer, Joergen Binningsboe, Aamund Bremer, Steinar Noem, Francis Pouatcha, Jacob Ideskog, Hannes Tschofenig, and Aaron Parecki for their valuable feedback to this specification.¶