Internet-Draft | OAuth 2.0 Direct Interaction Grants | December 2022 |
Parecki, et al. | Expires 24 June 2023 | [Page] |
This document extends the OAuth 2.0 Authorization Framework [RFC6749] with new grant types to support multi-factor authentication as well as alternatives to password authentication. These can be used by applications that want to control the user experience of the process of obtaining authorization from the user.¶
In many cases, this can provide an entirely browserless experience suited for native applications, delegating to the browser in unexpected, high risk, or error conditions.¶
While a fully-delegated approach using the 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. It should only be considered when there are usability concerns with a redirect-based approach, such as for native mobile or desktop applications.¶
This note is to be removed before publishing as an RFC.¶
The latest revision of this draft can be found at https://aaronpk.github.io/oauth-direct-interaction-grant/draft-parecki-oauth-direct-interaction-grant.html. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-parecki-oauth-direct-interaction-grant/.¶
Discussion of this document takes place on the OAuth Working Group mailing list (mailto:oauth@ietf.org), which is archived at https://oauth.net. Subscribe at https://www.ietf.org/mailman/listinfo/oauth/.¶
Source for this draft and an issue tracker can be found at https://github.com/aaronpk/oauth-direct-interaction-grant.¶
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 24 June 2023.¶
Copyright (c) 2022 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.¶
TODO: Key points to address include problem description, the relationship to the step-up authentication spec (use of acr etc.), properties of the protocol (extensibility etc).¶
TODO: Mention the trust prerequisites for this to be useful. Absolutely not allowed for third-party apps. Designed for native apps, specifically first-party, when the AS and app are operated by the same entity, and the user understands them both as the same entity...¶
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¶
TODO: List terms defined in this specification.¶
The direct interaction grant may be initiated by the client or the authorization server.¶
The client may initiate the direct interaction grant as part of a sign-up flow, or as a result of an interaction with a resource provider that requires a step-up authentication (TODO: add reference to step-up auth)¶
The client-initiated direct interaction is shown below:¶
+-------------------+ | Authorization | (B)Authorization | Server | +----------+ Initiation Request |+-----------------+| (A)Client+---| Native |---------------------->|| Authorization || Starts| | Client | || Initiation || Flow +-->| |<----------------------|| Endpoint || | | (C)Authorization |+-----------------+| | | Initiation Response| | | | | | | | (D)Authorization |+-----------------+| | | Challenge Request || Authorization || | |---------------------->|| Challenge || | | || Endpoint || | |<----------------------|+-----------------+| | | (E) Authorization | | | | Challenge Response| | | | | | (F)User +---| | | | Action | | | | | +-->| | (G) Authorization | | | | Grant |+-----------------+| | |---------------------->|| Token || | | || Endpoint || | |<----------------------|| || | | (H) Access Token |+-----------------+| | | | | +----------+ +-------------------+¶
Figure: Native Client Initiated Direct Interaction Grant¶
The Authorization Server may initiate the direct interaction grant when the client accesses the Token Endpoint. This allows the Authorization Server to request additional authentication methods to be presented before issuing an access token. This can happen on any grant type request to the token endpoint, such as a refresh token request.¶
The authorization-server-initiated direct interaction is shown below:¶
+-------------------+ | Authorization | (A)Authorization | Server | +----------+ Grant |+-----------------+| | Native |---------------------->|| Token || | Client | || Endpoint || | |<----------------------|| || | | (B)Authorization |+-----------------+| | | Server Challenge | | | | | | | | (C)Authorization |+-----------------+| | | Challenge Request || Authorization || | |---------------------->|| Challenge || | | || Endpoint || | |<----------------------|+-----------------+| | | (D) Authorization | | | | Challenge Response| | | | | | (E)User +---| | | | Action | | | | | +-->| | (F) Authorization | | | | Grant |+-----------------+| | |---------------------->|| Token || | | || Endpoint || | |<----------------------|| || | | (G) Access Token |+-----------------+| | | | | +----------+ +-------------------+¶
Figure: Authorization Server Initiated Direct Interaction Grant¶
This document defines several challenge type strings which are used by the client to indicate the supported challenge types and by the authorization server to instruct the client which challenge type to use.¶
otp
defined in Section 7.2.1¶
oob
defined in Section 7.2.2¶
recovery-code
defined in Section 7.2.3¶
redirect
defined in Section 7.2.4¶
Other specifications may extend this document with additional challenge types.¶
Authorization initiation endpoint¶
Authorization challenge endpoint¶
Token endpoint¶
Not every authorization grant type utilizes all endpoints. Extension grant types MAY define additional endpoints as needed.¶
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 adds additional grant types used at the token endpoint, as well as extends the token endpoint response to allow the authorization server to indicate that further authentication of the user is required.¶
Extension Grant Types¶
TODO: Clarify difference between mfa-otp and otp¶
Upon any request to the token endpoint, 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 authorization grant is insufficiently authorized, but another access token request MAY succeed if an additional authorization grant is presented.¶
In addition to the response parameters defined in Section 5.2 of
OAuth 2.0 [RFC6749], the following parameters MUST be included in the
response when the error code is set to mfa_required
:¶
MFA token value associated with the ongoing authorization session.¶
For example:¶
HTTP/1.1 403 Forbidden Content-Type: application/json;charset=UTF-8 Cache-Control: no-store { "error": "mfa_required", "mfa_token": "uY29tL2F1dGhlbnRpY" }¶
This specification defines new grant types at the token endpoint, providing a way for a client to obtain an access token given any of the MFA challenges previously described.¶
The client makes a request to the token endpoint by adding the
following parameters using the application/x-www-form-urlencoded
format with a character encoding of UTF-8 in the HTTP request body:¶
REQUIRED. urn:ietf:params:oauth:grant-type:mfa-otp
¶
REQUIRED. The one-time password generated by a device. e.g. 123456¶
REQUIRED. The MFA token, "mfa_token" from the prior authorization challenge error response¶
REQUIRED if the client is not authenticating with the authorization server.¶
For example:¶
POST /token HTTP/1.1 Host: server.example.com Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=urn:ietf:params:oauth:grant-type:mfa-otp &otp=123456&mfa_token=uY29tL2F1dGhlbnRpY¶
The authorization server MUST:¶
client_id
in the request,¶
The client makes a request to the token endpoint by adding the
following parameters using the application/x-www-form-urlencoded
format with a character encoding of UTF-8 in the HTTP request body:¶
REQUIRED. urn:ietf:params:oauth:grant-type:mfa-oob
¶
REQUIRED. The out-of-band transaction code, oob_code
from the
authorization challenge, defined in Section 7.2.2¶
REQUIRED, if the binding method of the authorization challenge is set to "prompt".¶
REQUIRED. The MFA token, "mfa_token" from the prior authorization challenge error response, defined in Section 6.¶
REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1 of OAuth 2.0 [RFC6749].¶
If the client type is confidential or the client was issued client credentials (or assigned other authentication requirements), the client MUST authenticate with the authorization server as described in Section 3.2.1 of OAuth 2.0 [RFC6749].¶
For example, the client makes the following HTTP request using transport-layer security (with extra line breaks for display purposes only):¶
POST /token HTTP/1.1 Host: server.example.com Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=urn:ietf:params:oauth:grant-type:mfa-oob &oob_code=GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS &binding_code=123456&mfa_token=uY29tL2F1dGhlbnRpY¶
The authorization server MUST:¶
client_id
in the request,¶
In addition to the error codes defined in Section 5.2 of OAuth 2.0 [RFC6749], the following error codes are specific for the out-of-band authorization grant in token endpoint responses:¶
The authorization request is still pending as the out-of-band
authorization operation has not yet completed. The client SHOULD
repeat the access token request to the token endpoint (a process
known as polling). Before each new request, the client MUST wait
at least the number of seconds specified by the interval
parameter of the authorization challenge (see Section X), or 5
seconds if none was provided, and respect any increase in the
polling interval required by the slow_down
error.¶
A variant of "authorization_pending", the authorization request is still pending and polling should continue, but the interval MUST be increased by 5 seconds for this and all subsequent requests.¶
The authorization request was denied.¶
The "oob_code" or "mfa_token" has expired, and the authorization session has concluded. The client MAY commence a new authorization session but SHOULD wait for user interaction before restarting to avoid unnecessary polling.¶
The authorization_pending
and slow_down
error codes define
particularly unique behavior, as they indicate that the OAuth client
should continue to poll the token endpoint by repeating the token
request (implementing the precise behavior defined above). If the
client receives an error response with any other error code, it MUST
stop polling and SHOULD react accordingly, for example, by displaying
an error to the user.¶
On encountering a connection timeout, clients MUST unilaterally reduce their polling frequency before retrying. The use of an exponential backoff algorithm to achieve this, such as doubling the polling interval on each such connection timeout, is RECOMMENDED.¶
The error codes and client behavior specified in this section are intentionally identical to those defined by OAuth 2.0 Device Authorization Grant [RFC8628].¶
The client makes a request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded" format with a character encoding of UTF-8 in the HTTP request body:¶
REQUIRED. urn:ietf:params:oauth:grant-type:mfa-recovery-code
¶
REQUIRED. The recovery code.¶
REQUIRED. The MFA token, "mfa_token" from the prior authorization challenge error response, defined in Section 6.¶
REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1 of OAuth 2.0 [RFC6749].¶
If the client type is confidential or the client was issued client credentials (or assigned other authentication requirements), the client MUST authenticate with the authorization server as described in Section 3.2.1 of OAuth 2.0 [RFC6749].¶
For example, the client makes the following HTTP request using transport-layer security (with extra line breaks for display purposes only):¶
POST /token HTTP/1.1 Host: server.example.com Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=urn:ietf:params:oauth:grant-type:mfa-recovery-code &recovery_code=WDJB-MJHT&mfa_token=uY29tL2F1dGhlbnRpY¶
The authorization server MUST:¶
client_id
in the request,¶
In addition to the parameters defined in Section 5.1 of OAuth 2.0 [RFC6749], the following additional parameters are specified for the recovery code grant:¶
OPTIONAL. A newly issued recovery code, in which case the client MUST discard the old recovery code and replace it with the new recovery code.¶
TODO: Do most systems currently give the user new recovery codes during this flow?¶
No changes are made to the authorization code flow after the client receives a redirect challenge.¶
TODO: OTP only, not in response to an MFA challenge.¶
The client makes a request to the token endpoint by adding the following parameters using the "application/x-www-form-urlencoded" format with a character encoding of UTF-8 in the HTTP request body:¶
REQUIRED. urn:ietf:params:oauth:grant-type:otp
¶
REQUIRED. The resource owner username.¶
REQUIRED. The one-time password generated by a device.¶
REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1 of OAuth 2.0 [RFC6749].¶
OPTIONAL. The device_session
if the client has one.¶
TODO: OOB only, not in response to an MFA challenge. Looks almost just like the MFA+OOB grant, just without the mfa_token.¶
TODO: Define passkey grant.¶
QUESTION: do we need device session as a seperate parameter, or can it be replaced by MFA token?¶
In addition to the parameters defined in Section 5.1 of OAuth 2.0 [RFC6749], the following additional parameters are specified for the token response for any grant type defined by or extended from this specification.¶
OPTIONAL. The device session contains relevant data to the device and the current user authenticated with the device.¶
The device session is completely opaque to the client, and as such the AS MUST adequately protect the value such as using a JWE if the AS is not maintaining state on the backend.¶
The device session can be used by the client on a subsequent authorization initiation request, described in Section 5, or in an authorization challenge request, described in Section 7.1.¶
TODO: Describe how the AS could return a challenge to the client on the normal refresh token request that tells the client they need to get the user to re-authenticate or provide an MFA token.¶
(No normative changes are required beyond what has already been described in the draft at this point.)¶
TODO: Determine whether this could be used for an app with offline access wanting to challenge the user. E.g. an app doing monthly transfers between bank accounts, wanting to get the user to acknowledge an MFA challenge before proceeding with the transfer.¶
TODO Security¶
TODO: Describe the phishing risk this opens up since the client is collecting and providing all the user's information to the authorization server. The AS MAY decide to require the user go through a redirect flow at any stage of the process based on its own risk assessment.¶
TODO: Describe the likely lack of client authentication because this is expected to be deployed by native apps. Maybe mention alternatives to client authentication such as App Attestation, or using a risk engine to analyze other aspects of the request from the client.¶
TODO: Attackers may be able to query the AS with user IDs to learn whether an identifier corresponds to an active account and which types of authentication a particular account has configured. What mitigations needed here? Possibly avoiding returning an error for unrecognized identifiers.¶
This specification registers the following values in the IANA "OAuth URI" registry (IANA.OAuth.Parameters) established by [RFC6755].¶
URN: `urn:ietf:params:oauth:grant-type:...` Common Name: ... Change Controller: IESG Specification Document: URN: `urn:ietf:params:oauth:grant-type:...` Common Name: ... Change Controller: IESG Specification Document: URN: `urn:ietf:params:oauth:grant-type:...` Common Name: ... Change Controller: IESG Specification Document: URN: `urn:ietf:params:oauth:grant-type:...` Common Name: ... Change Controller: IESG Specification Document:¶
This specification registers the following values in the IANA "OAuth Extensions Error Registry" registry (IANA.OAuth.Parameters) established by [RFC6749].¶
Name: ...¶
TODO: Outlining these in the document will also help guide developers to understand what they can (and cannot) expect to be able to do. For each use case, briefly describe the expected outcome, and outline each step and which part of the spec accomplishes each step.¶
mfa_required
¶
mfa_required
error¶
This example describes how you can 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 AS 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.¶
{"challenge_type":"oob","oob_code":"...",etc}
¶
{"challenge_type":"oob","oob_code":"...",etc}
¶
e.g. user provides e-mail, is sent a verification code, and then uses the verification code to prove they control the e-mail. Can also be used for registration.¶
e.g. developer can query the authorisation server to determine what authentication methods are supported.¶
e.g. developer can query the authorisation server to determine what authentication methods are used for account recovery if one of the methods are lost.¶
e.g. the authorisation server may require the user to update a password or provide a new phone number, key or alternative e-mail address if it believes the existing mechanism is no longer trustworthy.¶
e.g. some scenarios don't benefit from a native implementation and may be more efficiently or securely implemented through the browser (e.g. error scenarios, password recovery, identity verification, social sign-in).¶
e.g. Ability to know mandatory and optional custom attributes configured on the authorisation server (can this be achieve through AS metadata instead of as part of the protocol)?¶
An AS may support multiple different authenticators, and a user may have set up only one. A client will not know which a user has set up ahead of time. The AS needs to drive the UI in the client login process depending on the configuration of the user account.¶
e.g. user selects password, provides phone for SMS codes, etc¶
e.g. user enters a new email, completes the email challenge, the AS creates a new account for them, then wants to enroll additional factors such as SMS¶
TODO: The client may receive a trigger from the resource server to initiate an authentication, possibly with a hint from the resource server in the form of an acr value, indicating it needs to initiate and authentications.¶
TBD: May need to reference the existing step-up authentication draft instead¶
If the initial set of information provided by the client is correct, the AS MAY choose to either respond immediately with a successful token response, or prompt the client for an additional challenge.¶
For example, the AS could first require the client prompt the user for a one-time-code they received via email, and then in a second step, ask the client to prompt the user¶
TODO acknowledge.¶