Network Working Group | M.B. Jones |
Internet-Draft | Microsoft |
Intended status: Standards Track | D. Hardt |
independent | |
D. Recordon | |
Jun 21, 2011 |
The OAuth 2.0 Protocol: Bearer Tokens
draft-ietf-oauth-v2-bearer-06
This specification describes how to use bearer tokens when accessing OAuth 2.0 protected resources.
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 http://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."
Copyright (c) 2011 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 (http://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 Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
OAuth enables clients to access protected resources by obtaining an access token, which is defined in [I-D.ietf-oauth-v2] as "a string representing an access authorization issued to the client", rather than using the resource owner's credentials.
Tokens are issued to clients by an authorization server with the approval of the resource owner. The client uses the access token to access the protected resources hosted by the resource server. This specification describes how to make protected resource requests when the OAuth access token is a bearer token.
This specification defines the use of bearer tokens with OAuth over HTTP [RFC2616] using TLS [RFC5246]. Other specifications may extend it for use with other transport protocols.
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this document are to be interpreted as described in [RFC2119].
This document uses the Augmented Backus-Naur Form (ABNF) notation of [I-D.ietf-httpbis-p1-messaging], which is based upon the Augmented Backus-Naur Form (ABNF) notation of [RFC5234]. Additionally, the following rules are included from [RFC2617]: auth-param and realm; from [RFC3986]: URI-Reference; and from [I-D.ietf-httpbis-p1-messaging]: RWS and quoted-string.
Unless otherwise noted, all the protocol parameter names and values are case sensitive.
All other terms are as defined in [I-D.ietf-oauth-v2].
OAuth provides a method for clients to access a protected resource on behalf of a resource owner. Before a client can access a protected resource, it must first obtain authorization (access grant) from the resource owner and then exchange the access grant for an access token (representing the grant's scope, duration, and other attributes). The client accesses the protected resource by presenting the access token to the resource server.
The access token provides an abstraction layer, replacing different authorization constructs (e.g. username and password, assertion) for a single token understood by the resource server. This abstraction enables issuing access tokens valid for a short time period, as well as removing the resource server's need to understand a wide range of authentication schemes.
+--------+ +---------------+ | |--(A)- Authorization Request ->| Resource | | | | Owner | | |<-(B)----- Access Grant -------| | | | +---------------+ | | | | Access Grant & +---------------+ | |--(C)--- Client Credentials -->| Authorization | | Client | | Server | | |<-(D)----- Access Token -------| | | | +---------------+ | | | | +---------------+ | |--(E)----- Access Token ------>| Resource | | | | Server | | |<-(F)--- Protected Resource ---| | +--------+ +---------------+
The abstract flow illustrated in Figure 1 describes the overall OAuth 2.0 protocol architecture. The following steps are specified within this document:
Clients SHOULD make authenticated requests with a bearer token using the Authorization request header field defined by [RFC2617]. Resource servers MUST accept authenticated requests using the Bearer HTTP authorization scheme as described in Section 2.1, and MAY support additional methods.
Alternatively, clients MAY transmit the access token in the HTTP body when using the application/x-www-form-urlencoded content type as described in Section 2.2; or clients MAY transmit the access token in the HTTP request URI in the query component as described in Section 2.3. Resource servers MAY support these alternative methods.
Clients SHOULD NOT use the request body or URI unless the Authorization request header field is not available, and MUST NOT use more than one method to transmit the token in each request. Because of the Security Considerations [sec-con] associated with the URI method, it SHOULD NOT be used unless no other method is feasible.
The Authorization request header field is used by clients to make authenticated requests with bearer tokens. The client uses the Bearer authentication scheme to transmit the access token in the request.
For example:
GET /resource HTTP/1.1 Host: server.example.com Authorization: Bearer vF9dft4qmT
The Authorization header field uses the framework defined by [RFC2617] as follows:
credentials = "Bearer" RWS access-token access-token = 1*( quoted-char / <"> ) quoted-char = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "(" / ")" / "*" / "+" / "-" / "." / "/" / ":" / "<" / "=" / ">" / "?" / "@" / "[" / "]" / "^" / "_" / "`" / "{" / "|" / "}" / "~" / "\" / "," / ";"
When including the access token in the HTTP request entity-body, the client adds the access token to the request body using the access_token parameter. The client MUST NOT use this method unless the following conditions are met:
The entity-body can include other request-specific parameters, in which case, the access_token parameter MUST be properly separated from the request-specific parameters by an & character (ASCII code 38).
For example, the client makes the following HTTP request using transport-layer security:
POST /resource HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded access_token=vF9dft4qmT
The application/x-www-form-urlencoded method SHOULD NOT be used except in application contexts where participating browsers do not have access to the Authorization request header field.
When including the access token in the HTTP request URI, the client adds the access token to the request URI query component as defined by [RFC3986] using the access_token parameter.
For example, the client makes the following HTTP request using transport-layer security:
GET /resource?access_token=vF9dft4qmT HTTP/1.1 Host: server.example.com
The HTTP request URI query can include other request-specific parameters, in which case, the access_token parameter MUST be properly separated from the request-specific parameters by an & character (ASCII code 38).
For example:
http://example.com/resource?x=y&access_token=vF9dft4qmT
Because of the Security Considerations [sec-con] associated with the URI method, it SHOULD NOT be used unless no other method is feasible.
If the protected resource request does not include authentication credentials or contains an invalid access token, the resource server MUST include the HTTP WWW-Authenticate response header field; it MAY include it in response to other conditions as well. The WWW-Authenticate header field uses the framework defined by [RFC2617] as follows:
challenge = "Bearer" [ RWS 1#param ] param = realm / scope / error / error-desc / error-uri / auth-param scope = "scope" "=" <"> scope-v *( SP scope-v ) <"> scope-v = 1*quoted-char quoted-char = ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "(" / ")" / "*" / "+" / "-" / "." / "/" / ":" / "<" / "=" / ">" / "?" / "@" / "[" / "]" / "^" / "_" / "`" / "{" / "|" / "}" / "~" / "\" / "," / ";" error = "error" "=" quoted-string error-desc = "error_description" "=" quoted-string error-uri = "error_uri" "=" <"> URI-reference <">
The scope attribute is a space-delimited list of scope values indicating the required scope of the access token for accessing the requested resource. The scope attribute MUST NOT appear more than once.
If the protected resource request included an access token and failed authentication, the resource server SHOULD include the error attribute to provide the client with the reason why the access request was declined. The parameter value is described in Section 2.4.1. In addition, the resource server MAY include the error_description attribute to provide a human-readable explanation, and the error_uri attribute with an absolute URI identifying a human-readable web page explaining the error. The error, error_description, and error_uri attribute MUST NOT appear more than once. [[ add language and encoding information to error_description if the core specification does ]]
For example, in response to a protected resource request without authentication:
HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm="example"
And in response to a protected resource request with an authentication attempt using an expired access token:
HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm="example" error="invalid_token", error_description="The access token expired"
When a request fails, the resource server responds using the appropriate HTTP status code (typically, 400, 401, or 403), and includes one of the following error codes in the response:
If the request lacks any authentication information (i.e. the client was unaware authentication is necessary or attempted using an unsupported authentication method), the resource server SHOULD NOT include an error code or other error information.
For example:
HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer realm="example"
This section describes the relevant security threats regarding token handling when using bearer tokens and describes how to mitigate these threats.
The following list presents several common threats against protocols utilizing some form of tokens. This list of threats is based on NIST Special Publication 800-63 [NIST800-63]. Since this document builds on the OAuth 2.0 specification, we exclude a discussion of threats that are described there or in related documents.
A large range of threats can be mitigated by protecting the contents of the token by using a digital signature or a Message Authentication Code (MAC). Alternatively, a bearer token can contain a reference to authorization information, rather than encoding the information directly. Such references MUST be infeasible for an attacker to guess; using a reference may require an extra interaction between a server and the token issuer to resolve the reference to the authorization information.
This document does not specify the encoding or the contents of the token; hence detailed recommendations for token integrity protection are outside the scope of this document. We assume that the token integrity protection is sufficient to prevent the token from being modified.
To deal with token redirect, it is important for the authorization server to include the identity of the intended recipients (the audience), typically a single resource server (or a list of resource servers), in the token. Restricting the use of the token to a specific scope is also recommended.
To provide protection against token disclosure, confidentiality protection is applied via TLS [RFC5246] with a ciphersuite that offers confidentiality protection. This requires that the communication interaction between the client and the authorization server, as well as the interaction between the client and the resource server, utilize confidentiality protection. Since TLS is mandatory to implement and to use with this specification, it is the preferred approach for preventing token disclosure via the communication channel. For those cases where the client is prevented from observing the contents of the token, token encryption has to be applied in addition to the usage of TLS protection.
To deal with token capture and replay, the following recommendations are made: First, the lifetime of the token has to be limited by putting a validity time field inside the protected part of the token. Note that using short-lived (one hour or less) tokens significantly reduces the impact of one of them being leaked. Second, confidentiality protection of the exchanges between the client and the authorization server and between the client and the resource server MUST be applied, for instance, through the use of TLS [RFC5246]. As a consequence, no eavesdropper along the communication path is able to observe the token exchange. Consequently, such an on-path adversary cannot replay the token. Furthermore, when presenting the token to a resource server, the client MUST verify the identity of that resource server, as per [RFC2818]. Note that the client MUST validate the TLS certificate chain when making these requests to protected resources. Presenting the token to an unauthenticated and unauthorized resource server or failing to validate the certificate chain will allow adversaries to steal the token and gain unauthorized access to protected resources.
This specification registers the following access token type in the OAuth Access Token Type Registry.
[NIST800-63] | Burr, W., Dodson, D., Perlner, R., Polk, T., Gupta, S. and E. Nabbus, "NIST Special Publication 800-63-1, INFORMATION SECURITY", December 2008. |
[I-D.ietf-httpbis-p7-auth] | Fielding, R, Gettys, J, Mogul, J, Nielsen, H, Masinter, L, Leach, P, Berners-Lee, T and J Reschke, "HTTP/1.1, part 7: Authentication", Internet-Draft draft-ietf-httpbis-p7-auth-13, March 2011. |
The following people contributed to preliminary versions of this document: Blaine Cook (BT), Brian Eaton (Google), Yaron Goland (Microsoft), Brent Goldman (Facebook), Raffi Krikorian (Twitter), Luke Shepard (Facebook), and Allen Tom (Yahoo!). The content and concepts within are a product of the OAuth community, the WRAP community, and the OAuth Working Group.
The OAuth Working Group has dozens of very active contributors who proposed ideas and wording for this document, including: Michael Adams, Andrew Arnott, Dirk Balfanz, Brian Campbell, Leah Culver, Bill de hÓra, Brian Ellin, Igor Faynberg, George Fletcher, Tim Freeman, Evan Gilbert, Justin Hart, John Kemp, Eran Hammer-Lahav, Chasen Le Hara, Michael B. Jones, Torsten Lodderstedt, Eve Maler, James Manger, Laurence Miao, Chuck Mortimore, Anthony Nadalin, Justin Richer, Peter Saint-Andre, Nat Sakimura, Rob Sayre, Marius Scurtescu, Naitik Shah, Justin Smith, Jeremy Suriel, Christian Stübner, Paul Tarjan, and Franklin Tse.
[[ to be removed by the RFC editor before publication as an RFC ]]
-06
-05
-04
-03
-02
-01
-00