Internet-Draft | OAuth for First-Party Apps | October 2024 |
Parecki, et al. | Expires 11 April 2025 | [Page] |
This document defines the Authorization Challenge Endpoint, which supports a first-party client that wants to control the process of obtaining authorization from the user using a native experience.¶
In many cases, this can provide an entirely browserless OAuth 2.0 experience suited for native applications, only delegating to the browser in unexpected, high risk, or error conditions.¶
This note is to be removed before publishing as an RFC.¶
The latest revision of this draft can be found at https://drafts.oauth.net/oauth-first-party-apps/draft-ietf-oauth-first-party-apps.html. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-ietf-oauth-first-party-apps/.¶
Discussion of this document takes place on the Web Authorization Protocol Working Group mailing list (mailto:[email protected]), which is archived at https://mailarchive.ietf.org/arch/browse/oauth/. Subscribe at https://www.ietf.org/mailman/listinfo/oauth/.¶
Source for this draft and an issue tracker can be found at https://github.com/oauth-wg/oauth-first-party-apps.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 11 April 2025.¶
Copyright (c) 2024 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://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
This document, OAuth for First-Party Apps (FiPA),
extends the OAuth 2.0 Authorization Framework [RFC6749] with
a new endpoint, authorization_challenge_endpoint
, to support first-party
applications that want to control the process of obtaining authorization from
the user using a native experience.¶
The client collects any initial information from the user and POSTs that information as well as information about the client's request to the Authorization Challenge Endpoint, and receives either an authorization code or an error code in response. The error code may indicate that the client can continue to prompt the user for more information, or can indicate that the client needs to launch a browser to have the user complete the flow in a browser.¶
The Authorization Challenge Endpoint is used to initiate the OAuth flow in place of redirecting or launching a browser to the authorization endpoint.¶
While a fully-delegated approach using the redirect-based Authorization Code grant is generally preferred, this draft provides a mechanism for the client to directly interact with the user. This requires a high degree of trust between the authorization server and the client, as there typically is for first-party applications. It should only be considered when there are usability concerns with a redirect-based approach, such as for native mobile or desktop applications.¶
This draft also extends the token response (typically for use in response to a refresh token request) and resource server response to allow the authorization server or resource server to indicate that the client should re-request authorization from the user. This can include requesting step-up authentication by including parameters defined in [RFC9470] as well.¶
This specification MUST only be used by first-party applications, which is when the authorization server and application are controlled by the same entity and the user understands them both as the same entity.¶
This specification MUST NOT be used by third party applications, and the authorization server SHOULD take measures to prevent use by third party applications. (e.g. only enable this grant for certain client IDs, and take measures to authenticate first-party apps when possible.)¶
Using this specification in scenarios other than those described will lead to unintended security and privacy problems for users and service providers.¶
This specification is designed to be used by first-party native applications, which includes both mobile and desktop applications.¶
If you provide multiple apps and expect users to use multiple apps on the same device, there may be better ways of sharing a user's login between the apps other than each app implementing this specification or using an SDK that implements this specification. For example, [OpenID.Native-SSO] provides a mechanism for one app to obtain new tokens by exchanging tokens from another app, without any user interaction. See Section 9.7 for more details.¶
The scope of this specification is limited to first-party applications. Please review the entirety of Section 9, and when more than one first-party application is supported, Section 9.7.¶
While this draft provides the framework for a native OAuth experience, each implementation will need to define the specific behavior that it expects from OAuth clients interacting with the authorization server. While this lack of clearly defining the details would typically lead to less interoperability, it is acceptable in this case since we intend this specification to be deployed in a tightly coupled environment since it is only applicable to first-party applications.¶
It is important to consider the user experience implications of different authentication challenges as well as the device with which the user is attempting to authorize.¶
For example, requesting a user to enter a password on a limited-input device (e.g. TV) creates a lot of user friction while also exposing the user's password to anyone else in the room. On the other hand, using a challenge method that involves, for example, a fingerprint reader on the TV remote allowing for a FIDO2 passkey authentication would be a good experience.¶
The Authorization Server SHOULD consider the user's device when presenting authentication challenges and developers SHOULD consider whether the device implementing this specification can provide a good experience for the user. If the combination of user device and authentication challenge methods creates a lot of friction or security risk, consider using a specification like OAuth 2.0 Device Authorization Grant [RFC8628]. If selecting OAuth 2.0 Device Authorization Grant [RFC8628] which uses a cross-device authorization mechanism, please incorporate the security best practices identified in Cross-Device Flows: Security Best Current Practice [I-D.ietf-oauth-cross-device-security].¶
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", "Authorization Code", "Authorization Endpoint", "Authorization Server" (AS), "Client", "Client Authentication", "Client Identifier", "Client Secret", "Grant Type", "Protected Resource", "Redirection URI", "Refresh Token", "Resource Owner", "Resource Server" (RS) and "Token Endpoint" defined by [RFC6749].¶
TODO: Replace RFC6749 references with OAuth 2.1¶
There are three primary ways this specification extends various parts of an OAuth system.¶
When the client uses a refresh token to obtain a new access token, the authorization server MAY respond with an error to indicate that re-authorization of the user is required.¶
When making a resource request to a resource server, the resource server MAY respond with an error according to OAuth 2.0 Step-Up Authentication Challenge Protocol [RFC9470], indicating that re-authorization of the user is required.¶
The token endpoint is used by the client to obtain an access token by presenting its authorization grant or refresh token, as described in Section 3.2 of OAuth 2.0 [RFC6749].¶
This specification extends the token endpoint response to allow the authorization server to indicate that further authentication of the user is required.¶
The client makes a request to the token endpoint using the authorization code it obtained from the authorization challenge endpoint.¶
This specification does not define any additional parameters beyond the token request parameters defined in Section 4.1.3 of [RFC6749]. However, notably, the redirect_uri
parameter will not be included in this request, because no redirect_uri
parameter was included in the authorization request.¶
This specification extends the OAuth 2.0 [RFC6749] token response
defined in Section 5.1 with the additional parameter auth_session
, defined in Section 5.3.1.¶
An example successful token response is below:¶
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store { "access_token": "2YotnFZFEjr1zCsicMWpAA", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA", "auth_session": "uY29tL2F1dGhlbnRpY" }¶
The response MAY include an auth_session
parameter which the client is expected to include on any subsequent requests to the authorization challenge endpoint, as described in Section 5.3.1. The auth_session
parameter MAY also be included even if the authorization code was obtained through a traditional OAuth authorization code flow rather than the flow defined by this specification.¶
Including the auth_session
parameter in the token response enables flows such as step-up authentication [RFC9470], so that the authorization server can restore the context of a previous session and prompt only for the needed step-up factors. See Appendix A.7 for an example application.¶
Upon any request to the token endpoint, including a request with a valid refresh token, the authorization server can respond with an authorization challenge instead of a successful access token response.¶
An authorization challenge error response is a particular type of error response as defined in Section 5.2 of OAuth 2.0 [RFC6749] where the error code is set to the following value:¶
The presented authorization is insufficient, and the authorization server is requesting the client take additional steps to complete the authorization.¶
Additionally, the response MAY contain an auth_session
parameter which the client is expected to include on a subsequent request to the authorization challenge endpoint.¶
OPTIONAL. The optional auth session value allows the authorization server to
associate subsequent requests by this client with an ongoing
authorization request sequence. The client MUST include
the auth_session
in follow-up requests to the challenge
endpoint if it receives one along with the error response.¶
For example:¶
HTTP/1.1 403 Forbidden Content-Type: application/json Cache-Control: no-store { "error": "insufficient_authorization", "auth_session": "uY29tL2F1dGhlbnRpY" }¶
Step-Up Authentication [RFC9470] defines new error code values that a resource server can use to tell the client to start a new authorization request including acr_values
and max_age
from [OpenID]. Upon receiving this error response, the client starts a new first-party authorization request at the authorization challenge endpoint, and includes the acr_values
, max_age
and scope
that were returned in the error response.¶
This specification does not define any new parameters for the resource server error response beyond those defined in [RFC9470] and [RFC6750].¶
First-party applications are applications that are controlled by the same entity as the authorization server used by the application, and the user understands them both as the same entity.¶
For first-party applications, it is important that the user recognizes the application and authorization server as belonging to the same brand. For example, a bank publishing their own mobile application.¶
Because this specification enables a client application to interact directly with the end user, and the application handles sending any information collected from the user to the authorization server, it is expected to be used only for first-party applications when the authorization server also has a high degree of trust of the client.¶
This specification is not prescriptive on how the Authorization Server establishes its trust in the first-partyness of the application. For mobile platforms, most support some mechanism for application attestation that can be used to identify the entity that created/signed/uploaded the app to the app store. App attestation can be combined with other mechanisms like Dynamic Client Registration [RFC7591] to enable strong client authentication in addition to client verification (first-partyness). The exact steps required are out of scope for this specification. Note that applications running inside a browser (e.g. Single Page Apps) context it is much more difficult to verify the first-partyness of the client. Please see Section 9.8 for additional details.¶
There are two ways using this specification increases the risk of phishing.¶
Malicious application: With this specification, the client interacts directly with the end user, collecting information provided by the user and sending it to the authorization server. If an attacker impersonates the client and successfully tricks a user into using it, they may not realize they are giving their credentials to the malicious application.¶
User education: In a traditional OAuth deployment using the redirect-based authorization code flow, the user will only ever enter their credentials at the authorization server, and it is straightforward to explain to avoid entering credentials in other "fake" websites. By introducing a new place the user is expected to enter their credentials using this specification, it is more complicated to teach users how to recognize other fake login prompts that might be attempting to steal their credentials.¶
Because of these risks, the authorization server MAY decide to require that the user go through a redirect-based flow at any stage of the process based on its own risk assessment.¶
The authorization challenge endpoint is capable of directly receiving user credentials and returning authorization codes. This exposes a new vector to perform credential stuffing attacks, if additional measures are not taken to ensure the authenticity of the application.¶
An authorization server may already have a combination of built-in or 3rd party security tools in place to monitor and reduce this risk in browser-based authentication flows. Implementors SHOULD consider similar security measures to reduce this risk in the authorization challenge endpoint. Additionally, the attestation APIs SHOULD be used when possible to assert a level of confidence to the authorization server that the request is originating from an application owned by the same party.¶
Typically, mobile and desktop applications are considered "public clients" in OAuth, since they cannot be shipped with a statically configured set of client credentials [RFC8252]. Because of this, client impersonation should be a concern of anyone deploying this pattern. Without client authentication, a malicious user or attacker can mimick the requests the application makes to the authorization server, pretending to be the legitimate client.¶
Implementers SHOULD consider additional measures to limit the risk of client impersonation, such as using attestation APIs available from the operating system.¶
Tokens issued in response to an authorization challenge request SHOULD be sender constrained to mitigate the risk of token theft and replay.¶
Proof-of-Possession techniques constrain tokens by binding them to a cryptographic key. Whenever the token is presented, it MUST be accompanied by a proof that the client presenting the token also controls the cryptographic key bound to the token. If a proof-of-possession sender constrained token is presented without valid proof of possession of the cryptographic key, it MUST be rejected.¶
DPoP ([RFC9449]) is an application-level mechanism for sender-constraining OAuth [RFC6749] access and refresh tokens. If DPoP is used to sender constrain tokens, the client SHOULD use DPoP for every token request to the Authorization Server and interaction with the Resource Server.¶
DPoP includes an optional capability to bind the authorization code to the DPoP key to enable end-to-end binding of the entire authorization flow. Given the back-channel nature of this specification, there are far fewer opportunities for an attacker to access the authorization code and PKCE code verifier compared to the redirect-based Authorization Code Flow. In this specification, the Authorization Code is obtained via a back-channel request. Despite this, omitting Authorization Code binding leaves a gap in the end-to-end protection that DPoP provides, so DPoP Authorization Code binding SHOULD be used.¶
The mechanism for Authorization Code binding with DPoP is similar as that defined for Pushed Authorization Requests (PARs) in Section 10.1 of [RFC9449]. In order to bind the Authorization Code with DPoP, the client MUST add the DPoP header to the Authorization Challenge Request. The authorization server MUST check the DPoP proof JWT that was included in the DPoP header as defined in Section 4.3 of [RFC9449]. The authorization server MUST ensure that the same key is used in all subsequent Authorization Challenge Requests, or in the eventual token request. The authorization server MUST reject subsequent Authorization Challenge Requests, or the eventual token request, unless a DPoP proof for the same key presented in the original Authorization Challenge Request is provided.¶
The above mechanism simplifies the implementation of the client, as it can attach the DPoP header to all requests to the authorization server regardless of the type of request. This mechanism provides a stronger binding than using the dpop_jkt
parameter, as the DPoP header contains a proof of possession of the private key.¶
It may be possible to use other proof of possession mechanisms to sender constrain access and refresh tokens. Defining these mechanisms are out of scope for this specification.¶
If the client and authorization server are using DPoP binding of access tokens and/or authorization codes, then the auth_session
value SHOULD be protected as well. The authorization server SHOULD associate the auth_session
value with the DPoP public key. This removes the need for the authorization server to include additional claims in the DPoP proof, while still benefitting from the assurance that the client presenting the proof has control over the DPoP key. To associate the auth_session
value with the DPoP public key, the authorization server:¶
MUST check that the same DPoP public key is being used when the client presents the DPoP proof.¶
MUST verify the DPoP proof to ensure the client controls the corresponding private key whenever the client includes the auth_session
in an Authorization Challenge Request as described in Section 5.1.¶
DPoP binding of the auth_session
value ensures that the context referenced by the auth_session
cannot be stolen and reused by another device.¶
This specification makes no requirements or assumptions on the lifetime of the auth_session
value. The lifetime and expiration is at the discretion of the authorization server, and the authorization server may choose to invalidate the value for any reason such as scheduled expiration, security events, or revocation events.¶
Clients MUST NOT make any assumptions or depend on any particular lifetime of the auth_session
value.¶
When multiple first-party applications are supported by the AS, then it is important to consider a number of additional risks. These risks fall into two main categories: Experience Risk and Technical Risk which are described below.¶
Any time a user is asked to provide the authentication credentials in user experiences that differ, it has the effect of increasing the likelihood that the user will fall prey to a phishing attack because they are used to entering credentials in different looking experiences. When multiple first-party applications are supported, the implementation MUST ensure the native experience is identical across all the first-party applications.¶
Another experience risk is user confusion caused by different looking experiences and behaviors. This can increase the likelihood the user will not complete the authentication experience for the first-party application.¶
In addition to the experience risks, multiple implementations in first-party applications increases the risk of an incorrect implementation as well as increasing the attack surface as each implementation may expose its own weaknesses.¶
To address these risks, when multiple first-party applications must be supported, and other methods such as [OpenID.Native-SSO] are not applicable, it is RECOMMENDED that a client-side SDK be used to ensure the implementation is consistent across the different applications and to ensure the user experience is identical for all first-party apps.¶
Single Page Applications (SPA) run in a scripting language inside the context of a browser instance. This environment poses several unique challenges compared to native applications, in particular:¶
Significant attack vectors due to the possibility of Cross-Site Scripting (XSS) attacks¶
Fewer options to securely attest to the first-partyness of a browser based application¶
See [I-D.ietf-oauth-browser-based-apps] for a detailed discussion of the risks of XSS attacks in browsers.¶
Additionally, the nature of a Single-Page App means the user is already in a browser context, so the user experience cost of doing a full page redirect or a popup window for the traditional OAuth Authorization Code Flow is much less than the cost of doing so in a native application. The complexity and risk of implementing this specification in a browser likely does not outweigh the user experience benefits that would be gained in that context.¶
For these reasons, it is NOT RECOMMENDED to use this specification in browser-based applications.¶
IANA has (TBD) registered the following values in the IANA "OAuth Parameters" registry of [IANA.oauth-parameters] established by [RFC6749].¶
Parameter name: auth_session
¶
Parameter usage location: token response¶
Change Controller: IETF¶
Specification Document: Section 5.4 of this specification¶
IANA has (TBD) registered the following values in the IANA "OAuth Authorization Server Metadata" registry of [IANA.oauth-parameters] established by [RFC8414].¶
Metadata Name: authorization_challenge_endpoint
¶
Metadata Description: URL of the authorization server's authorization challenge endpoint.¶
Change Controller: IESG¶
Specification Document: Section 4.1 of [[ this specification ]]¶
This section provides non-normative examples of how this specification may be used to support specific use cases.¶
A user may log in with a passkey (without a password).¶
The Client collects the username from the user.¶
The Client sends an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1) including the username.¶
The Authorization Server verifies the username and returns a challenge¶
The Client signs the challenge using the platform authenticator, which results in the user being prompted for verification with biometrics or a PIN.¶
The Client sends the signed challenge, username, and credential ID to the Authorization Challenge Endpoint (Section 4.1).¶
The Authorization Server verifies the signed challenge and returns an Authorization Code.¶
The Client requests an Access Token and Refresh Token by issuing a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the requested tokens.¶
In a passwordless One-Time Password (OTP) scheme, the user is in possession of a one-time password generator. This generator may be a hardware device, or implemented as an app on a mobile phone. The user provides a user identifier and one-time password, which is verified by the Authorization Server before it issues an Authorization Code, which can be exchanged for an Access and Refresh Token.¶
The Client collects username and OTP from user.¶
The Client sends an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1) including the username and OTP.¶
The Authorization Server verifies the username and OTP and returns an Authorization Code.¶
The Client requests an Access Token and Refresh Token by issuing a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the requested tokens.¶
A user may be required to provide an e-mail confirmation code as part of an authentication ceremony to prove they control an e-mail address. The user provides an e-mail address and is then required to enter a verification code sent to the e-mail address. If the correct verification code is returned to the Authorization Server, it issues Access and Refresh Tokens.¶
The Client collects an e-mail address from the user.¶
The Client sends the e-mail address in an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1).¶
The Authorization Server sends a verification code to the e-mail address and returns an Error Response (Section 5.2.2) including "error": "insufficient_authorization"
, "auth_session"
and a custom property indicating that an e-mail verification code must be entered.¶
The Client presents a user experience guiding the user to copy the e-mail verification code to the Client. Once the e-mail verification code is entered, the Client sends an Authorization Challenge Request to the Authorization Challenge Endpoint, including the e-mail verification code as well as the auth_session
parameter returned in the previous Error Response.¶
The Authorization Server uses the auth_session
to maintain the session and verifies the e-mail verification code before issuing an Authorization Code to the Client.¶
The Client sends the Authorization Code in a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the Access Token and Refresh Token.¶
An alternative version of this verification involves the user clicking a link in an email rather than manually entering a verification code. This is typically done for email verification flows rather than inline in a login flow. The protocol-level details remain the same for the alternative flow despite the different user experience. All steps except step 4 above remain the same, but the client presents an alternative user experience for step 4 described below:¶
The Client presents a message to the user instructing them to click the link sent to their email address. The user clicks the link in the email, which contains the verification code in the URL. The URL launches the app providing the verification code to the Client. The Client sends the verification code and auth_session
to the Authorization Challenge Endpoint.¶
A user may be required to provide a confirmation code as part of an authentication ceremony to prove they control a mobile phone number. The user provides a phone number and is then required to enter a confirmation code sent to the phone. If the correct confirmation code is returned to the Authorization Server, it issues Access and Refresh Tokens.¶
The Client collects a mobile phone number from the user.¶
The Client sends the phone number in an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1).¶
The Authorization Server sends a confirmation code to the phone number and returns an Error Response (Section 5.2.2) including "error": "insufficient_authorization"
, "auth_session"
and a custom property indicating that a confirmation code must be entered.¶
The Client presents a user experience guiding the user to enter the confirmation code. Once the code is entered, the Client sends an Authorization Challenge Request to the Authorization Challenge Endpoint, including the confirmation code as well as the auth_session
parameter returned in the previous Error Response.¶
The Authorization Server uses the auth_session
to maintain the session context and verifies the code before issuing an Authorization Code to the Client.¶
The Client sends the Authorization Code in a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the Access Token and Refresh Token.¶
A client may be in possession of an Access and Refresh Token as the result of a previous succesful user authentication. The user returns to the app a week later and accesses the app. The Client presents the Access Token, but receives an error indicating the Access Token is no longer valid. The Client presents a Refresh Token to the Authorization Server to obtain a new Access Token. If the Authorization Server requires user interaction for reasons based on its own policies, it rejects the Refresh Token and the Client re-starts the user authentication flow to obtain new Access and Refresh Tokens.¶
The Client has a short-lived access token and long-lived refresh token following a previous completion of an Authorization Grant Flow which included user authentication.¶
A week later, the user launches the app and tries to access a protected resource at the Resource Server.¶
The Resource Server responds with an error code indicating an invalid access token since it has expired.¶
The Client presents the refresh token to the Authorization Server to obtain a new access token (section 6 [RFC6749])¶
The Authorization Server responds with an error code indicating that an OTP from the user is required, as well as an auth_session
.¶
The Client prompts the user to enter an OTP.¶
The Client sends the OTP and auth_session
in an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1).¶
The Authorization Server verifies the auth_session
and OTP, and returns an Authorization Code.¶
The Client sends the Authorization Code in a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the requested tokens.¶
The Client presents the new Access Token to the Resource Server in order to access the protected resource.¶
A Client previously obtained an Access and Refresh Token after the user authenticated with an OTP. When the user attempts to access a protected resource, the Resource Server determines that it needs an additional level of authentication and triggers a step-up authentication, indicating the desired level of authentication using acr_values
and max_age
as defined in the Step-up Authentication specification. The Client initiates an authorization request with the Authorization Server indicating the acr_values
and max_age
parameters. The Authorization Server responds with error messages promptng for additional authentication until the acr_values
and max_age
values are satisfied before issuing fresh Access and Refresh Tokens.¶
The Client has a short-lived access token and long-lived refresh token following the completion of an Authorization Code Grant Flow which included user authentication.¶
When the Client presents the Access token to the Resource Server, the Resource Server determines that the acr
claim in the Access Token is insufficient given the resource the user wants to access and responds with an insufficient_user_authentication
error code, along with the desired acr_values
and desired max_age
.¶
The Client sends an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1) including the auth_session
, acr_values
and max_age
parameters.¶
The Authorization Server verifies the auth_session
and determines which authentication methods must be satisfied based on the acr_values
, and responds with an Error Response (Section 5.2.2) including "error": "insufficient_authorization"
and a custom property indicating that an OTP must be entered.¶
The Client prompts the user for an OTP, which the user obtains and enters.¶
The Client sends an Authorization Challenge Request to the Authorization Challenge Endpoint including the auth_session
and OTP.¶
The Authorization Server verifies the OTP and returns an Authorization Code.¶
The Client sends the Authorization Code in a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues an Access Token with the updated acr
value along with the Refresh Token.¶
The Client presents the Access Token to the Resources Server, which verifies that the acr
value meets its requirements before granting access to the protected resource.¶
This example describes how to use the mechanisms defined in this draft to create a complete user registration flow starting with an email address. In this example, it is the Authorization Server's policy to allow these challenges to be sent to email and phone number that were previously unrecognized, and creating the user account on the fly.¶
The Client collects a username from the user.¶
The Client sends an Authorization Challenge Request (Section 5.1) to the Authorization Challenge Endpoint (Section 4.1) including the username.¶
The Authorization Server returns an Error Response (Section 5.2.2) including "error": "insufficient_authorization"
, "auth_session"
, and a custom property indicating that an e-mail address must be collected.¶
The Client collects an e-mail address from the user.¶
The Client sends the e-mail address as part of a second Authorization Challenge Request to the Authorization Challenge Endpoint, along with the auth_session
parameter.¶
The Authorization Server sends a verification code to the e-mail address and returns an Error Response including "error": "insufficient_authorization"
, "auth_session"
and a custom property indicating that an e-mail verification code must be entered.¶
The Client presents a user experience guiding the user to copy the e-mail verification code to the Client. Once the e-mail verification code is entered, the Client sends an Authorization Challenge Request to the Authorization Challenge Endpoint, including the e-mail verification code as well as the auth_session
parameter returned in the previous Error Response.¶
The Authorization Server uses the auth_session
to maintain the session context, and verifies the e-mail verification code. It determines that it also needs a phone number for account recovery purposes and returns an Error Response including "error": "insufficient_authorization"
, "auth_session"
and a custom property indicating that a phone number must be collected.¶
The Client collects a mobile phone number from the user.¶
The Client sends the phone number in an Authorization Challenge Request to the Authorization Challenge Endpoint, along with the auth_session
.¶
The Authorization Server uses the auth_session
parameter to link the previous requests. It sends a confirmation code to the phone number and returns an Error Response including "error": "insufficient_authorization"
, "auth_session"
and a custom property indicating that a SMS confirmation code must be entered.¶
The Client presents a user experience guiding the user to enter the SMS confirmation code. Once the SMS verification code is entered, the Client sends an Authorization Challenge Request to the Authorization Challenge Endpoint, including the confirmation code as well as the auth_session
parameter returned in the previous Error Response.¶
The Authorization Server uses the auth_session
to maintain the session context, and verifies the SMS verification code before issuing an Authorization Code to the Client.¶
The Client sends the Authorization Code in a Token Request (Section 6) to the Token Endpoint.¶
The Authorization Server verifies the Authorization Code and issues the requested tokens.¶
In order to successfully implement this specification, the Authorization Server will need to define its own specific requirements for what values clients are expected to send in the Authorization Challenge Request (Section 5.1), as well as its own specific error codes in the Authorization Challenge Response (Section 5.2).¶
Below is an example of parameters required for a complete implementation that enables the user to log in with a username and OTP.¶
The client prompts the user to enter their username, and sends the username in an initial Authorization Challenge Request.¶
POST /authorize-challenge HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded username=alice &scope=photos &client_id=bb16c14c73415¶
The Authorization Server sends an error response indicating that an OTP is required.¶
HTTP/1.1 401 Unauthorized Content-Type: application/json Cache-Control: no-store { "error": "otp_required", "auth_session": "ce6772f5e07bc8361572f" }¶
The client prompts the user for an OTP, and sends a new Authorization Challenge Request.¶
POST /authorize-challenge HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded auth_session=ce6772f5e07bc8361572f &otp=555121¶
The Authorization Server validates the auth_session
to find the expected user, then validates the OTP for that user, and responds with an authorization code.¶
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store { "authorization_code": "uY29tL2F1dGhlbnRpY" }¶
The client sends the authorization code to the token endpoint.¶
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded grant_type=authorization_code &client_id=bb16c14c73415 &code=uY29tL2F1dGhlbnRpY¶
The Authorization Server responds with an access token and refresh token.¶
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store { "token_type": "Bearer", "expires_in": 3600, "access_token": "d41c0692f1187fd9b326c63d", "refresh_token": "e090366ac1c448b8aed84cbc07" }¶
This specification defines a new authorization flow the client can use to obtain an authorization grant. There are two primary reasons for designing the specification this way.¶
This enables existing OAuth implementations to make fewer modifications to existing code by not needing to extend the token endpoint with new logic. Instead, the new logic can be encapsulated in an entirely new endpoint, the output of which is an authorization code which can be redeemed for an access token at the existing token endpoint.¶
This also mirrors more closely the existing architecture of the redirect-based authorization code flow. In the authorization code flow, the client first initiates a request by redirecting a browser to the authorization endpoint, at which point the authorization server takes over with its own custom logic to authenticate the user in whatever way appropriate, possibly including interacting with other endpoints for the actual user authentication process. Afterwards, the authorization server redirects the user back to the client application with an authorization code in the query string. This specification mirrors the existing approach by having the client first make a POST request to the Authorization Challenge Endpoint, at which point the authorization server provides its own custom logic to authenticate the user, eventually returning an authorization code.¶
An alternative design would be to define new custom grant types for the different authentication factors such as WebAuthn, OTP, etc. The drawback to this design is that conceptually, these authentication methods do not map to an OAuth grant. In other words, the OAuth authorization grant captures the user's intent to authorize access to some data, and that authorization is represented by an authorization code, not by different methods of authenticating the user.¶
Another alternative option would be to have the Authorization Challenge Endpoint return an access token upon successful authentication of the user. This was deliberately not chosen, as this adds a new endpoint that tokens would be returned from. In most deployments, the Token Endpoint is the only endpoint that actually issues tokens, and includes all the implmentation logic around token binding, rate limiting, etc. Instead of defining a new endpoint that issues tokens which would have to have similar logic and protections, instead the new endpoint only issues authorization codes, which can be exchanged for tokens at the existing Token Endpoint just like in the redirect-based Authorization Code flow.¶
These design decisions should enable authorization server implementations to isolate and encapsulate the changes needed to support this specification.¶
-02¶
Fixed typos¶
Clarified resource server error response section¶
Added additional context to the Design Goals section¶
Clarified that further communication between client and AS can happen at proprietary endpoints¶
Changed invalid_grant
to invalid_session
¶
-01¶
Added clarification on use of authorization code binding when using DPoP with the authorization challenge endpoint.¶
Removed ash claim to simplify DPoP binding with auth_session value.¶
Fixed how "redirect to web" mechanism works with PKCE.¶
Added "intermediate requests" section to clarify these requests are out of scope, moved "auth session" description to that section.¶
-00¶
Renamed authorization_required
to insufficient_authorization
¶
Defined insufficient_authorization
on the Authorization Challenge Endpoint¶
Renamed device_session
to auth_session
¶
Added explicit method to indicate the client should restart the flow in a browser¶
Described how to use DPoP in conjunction with this spec¶
The authors would like to thank the attendees of the OAuth Security Workshop 2023 session in which this was discussed, as well as the following individuals who contributed ideas, feedback, and wording that shaped and formed the final specification:¶
Alejo Fernandez, Brian Campbell, Dick Hardt, Dmitry Telegin, Jeff Corrigan, John Bradley, Justin Richer, Mike Jones, Orie Steele, Tim Cappalli, Tobias Looker, Yaron Sheffer.¶