Documente Academic
Documente Profesional
Documente Cultură
0
Abstract
The OAuth protocol enables websites or applications (Consumers) to access Protected Resources from a web service (Service Provider) via an API, without requiring Users to disclose their Service Provider credentials to the Consumers. More generally, OAuth creates a freely-implementable and generic methodology for API authentication. An example use case is allowing printing service printer.example.com (the Consumer), to access private photos stored on photos.example.net (the Service Provider) without requiring Users to provide their photos.example.net credentials to printer.example.com. OAuth does not require a specific user interface or interaction pattern, nor does it specify how Service Providers authenticate Users, making the protocol ideally suited for cases where authentication credentials are unavailable to the Consumer, such as with OpenID. OAuth aims to unify the experience and implementation of delegated web service authentication into a single, community-driven protocol. OAuth builds on existing protocols and best practices that have been independently implemented by various websites. An open standard, supported by large and small providers alike, promotes a consistent and trusted experience for both application developers and the users of those applications.
License
This specification is made available under the OAuth Non-Assertion Covenant and Authors Contribution License For OAuth Specification 1.0 available athttp://oauth.net/license/core/1.0. Copyrights are licensed under the terms of the Creative Commons Attribution ShareAlike 3.0 license available athttp://creativecommons.org/licenses/by-sa/3.0.
Table of Contents
1. 2. 3. 4. Authors Notation and Conventions Definitions Documentation and Registration 4.1. Request URLs 4.2. Service Providers 4.3. Consumers 5. Parameters 5.1. Parameter Encoding
5.2. Consumer Request Parameters 5.3. Service Provider Response Parameters 5.4. OAuth HTTP Authorization Scheme 6. Authenticating with OAuth 6.1. Obtaining an Unauthorized Request Token 6.2. Obtaining User Authorization 6.3. Obtaining an Access Token 7. Accessing Protected Resources 8. Nonce and Timestamp 9. Signing Requests 9.1. Signature Base String 9.2. HMAC-SHA1 9.3. RSA-SHA1 9.4. PLAINTEXT 10. HTTP Response Codes Appendix A. Appendix A - Protocol Example Appendix A.1. Documentation and Registration Appendix A.2. Obtaining a Request Token Appendix A.3. Requesting User Authorization Appendix A.4. Obtaining an Access Token Appendix A.5. Accessing Protected Resources Appendix B. Security Considerations Appendix B.1. Credentials and Token Exchange Appendix B.2. PLAINTEXT Signature Method Appendix B.3. Confidentiality of Requests Appendix B.4. Spoofing by Counterfeit Servers Appendix B.5. Proxying and Caching of Authenticated Content Appendix B.6. Plaintext Storage of Credentials Appendix B.7. Secrecy of the Consumer Secret Appendix B.8. Phishing Attacks Appendix B.9. Scoping of Access Requests Appendix B.10. Entropy of Secrets Appendix B.11. Denial of Service / Resource Exhaustion Attacks Appendix B.12. Cryptographic Attacks Appendix B.13. Signature Base String Compatibility 11. References Authors Address
1. Authors
Mark Atwood (me@mark.atwood.name) Richard M. Conlan (zeveck@google.com) Blaine Cook (blaine@twitter.com) Leah Culver (leah@pownce.com) Kellan Elliott-McCrea (kellan@flickr.com)
Larry Halff (larry@ma.gnolia.com) Eran Hammer-Lahav (eran@hueniverse.com) Ben Laurie (benl@google.com) Chris Messina (chris@citizenagency.com) John Panzer (jpanzer@acm.org) Sam Quigley (quigley@emerose.com) David Recordon (david@sixapart.com) Eran Sandler (eran@yedda.com) Jonathan Sergent (sergent@google.com) Todd Sieling (todd@ma.gnolia.com) Brian Slesinsky (brian-oauth@slesinsky.org) Andy Smith (andy@jaiku.com)
3. Definitions
Service Provider: A web application that allows access via OAuth. User: An individual who has an account with the Service Provider. Consumer: A website or application that uses OAuth to access the Service Provider on behalf of the User. Protected Resource(s): Data controlled by the Service Provider, which the Consumer can access through authentication. Consumer Developer: An individual or organization that implements a Consumer. Consumer Key: A value used by the Consumer to identify itself to the Service Provider. Consumer Secret: A secret used by the Consumer to establish ownership of the Consumer Key. Request Token: A value used by the Consumer to obtain authorization from the User, and exchanged for an Access Token. Access Token:
A value used by the Consumer to gain access to the Protected Resources on behalf of the User, instead of using the Users Service Provider credentials. Token Secret: A secret used by the Consumer to establish ownership of a given Token. OAuth Protocol Parameters: Parameters with names beginning with oauth_.
http://sp.example.com/authorize
4.3. Consumers
The Consumer Developer MUST establish a Consumer Key and a Consumer Secret with the Service Provider. The Consumer Developer MAY also be required to provide additional information to the Service Provider upon registration.
5. Parameters
OAuth Protocol Parameter names and values are case sensitive. Each OAuth Protocol Parameters MUST NOT appear more than once per request, and are REQUIRED unless otherwise noted.
be upper case. Text names and values MUST be encoded as UTF-8 octets before percent-encoding them per [RFC3629].
oauth_token=ab3cd9j4ks73hf7g&oauth_token_secret=xyz4992k83j47x0b
It is RECOMMENDED that Service Providers accept the HTTP Authorization header. Consumers SHOULD be able to send OAuth Protocol Parameters in the OAuth Authorizationheader. The extension auth-scheme (as defined by [RFC2617]) is insensitive.
1. Parameter names and values are encoded per Parameter Encoding. 2. For each parameter, the name is immediately followed by an = character (ASCII code 61), a character (ASCII code 34), the parameter value (MAY be empty), and another character (ASCII code 34). 3. Parameters are separated by a comma character (ASCII code 44) and OPTIONAL linear whitespace per [RFC2617]. 4. The OPTIONAL realm parameter is added and interpreted per [RFC2617], section 1.2. For example:
Authorization: OAuth realm="http://sp.example.com/", oauth_consumer_key="0685bd9184jfhq22", oauth_token="ad180jjd733klru7", oauth_signature_method="HMAC-SHA1", oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D", oauth_timestamp="137131200", oauth_nonce="4572616e48616d6d65724c61686176", oauth_version="1.0"
For example:
To obtain a Request Token, the Consumer sends an HTTP request to the Service Providers Request Token URL. The Service Provider documentation specifies the HTTP method for this request, and HTTP POST is RECOMMENDED. The request MUST be signed and contains the following parameters: oauth_consumer_key: The Consumer Key. oauth_signature_method: The signature method the Consumer used to sign the request. oauth_signature: The signature as defined in Signing Requests. oauth_timestamp: As defined in Nonce and Timestamp. oauth_nonce: As defined in Nonce and Timestamp. oauth_version: OPTIONAL. If present, value MUST be 1.0 . Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present. Service Providers response to non-1.0 value is left undefined. Additional parameters: Any additional parameters, as defined by the Service Provider.
The Service Provider MUST first verify the Users identity before asking for consent. It MAY prompt the User to sign in if the User has not already done so. The Service Provider presents to the User information about the Consumer requesting access (as registered by the Consumer Developer). The information includes the duration of the access and the Protected Resources provided. The information MAY include other details specific to the Service Provider. The User MUST grant or deny permission for the Service Provider to give the Consumer access to the Protected Resources on behalf of the User. If the User denies the Consumer access, the Service Provider MUST NOT allow access to the Protected Resources. When displaying any identifying information about the Consumer to the User based on the Consumer Key, the Service Provider MUST inform the User if it is unable to assure the Consumers true identity. The method in which the Service Provider informs the User and the quality of the identity assurance is beyond the scope of this specification.
The Consumer exchanges the Request Token for an Access Token capable of accessing the Protected Resources. Obtaining an Access Token includes the following steps:
If successful, the Service Provider generates an Access Token and Token Secret and returns them in the HTTP response body as defined in Service Provider Response Parameters. The Access Token and Token Secret are stored by the Consumer and used when signing Protected Resources requests. The response contains the following parameters: oauth_token: The Access Token. oauth_token_secret: The Token Secret. Additional parameters: Any additional parameters, as defined by the Service Provider. If the request fails verification or is rejected for other reasons, the Service Provider SHOULD respond with the appropriate response code as defined in HTTP Response Codes. The Service Provider MAY include some further details about why the request was rejected in the HTTP response body as defined in Service Provider Response Parameters.
9. Signing Requests
All Token requests and Protected Resources requests MUST be signed by the Consumer and verified by the Service Provider. The purpose of signing requests is to prevent unauthorized parties from using the Consumer Key and Tokens when making Token requests or Protected Resources requests. The signature process encodes the Consumer Secret and Token Secret into a verifiable value which is included with the request. OAuth does not mandate a particular signature method, as each implementation can have its own unique requirements. The protocol defines three signature methods: HMAC-SHA1, RSA-SHA1, and PLAINTEXT, but Service Providers are free to implement and document their own methods. Recommending any particular method is beyond the scope of this specification. The Consumer declares a signature method in the oauth_signature_method parameter, generates a signature, and stores it in the oauth_signature parameter. The Service Provider verifies the signature as specified in each method. When verifying a Consumer signature, the Service Provider SHOULD check the request nonce to ensure it has not been used in a previous Consumer request. The signature process MUST NOT change the request parameter names or values, with the exception of the oauth_signature parameter.
The Signature Base String is a consistent reproducible concatenation of the request elements into a single string. The string is used as an input in hashing or signing algorithms. TheHMAC-SHA1 signature method provides both a standard and an example of using the Signature Base String with a signing algorithm to generate signatures. All the request parameters MUST be encoded as described in Parameter Encoding prior to constructing the Signature Base String.
The parameters are normalized into a single string as follows: 1. Parameters are sorted by name, using lexicographical byte value ordering. If two or more parameters share the same name, they are sorted by their value. For example:
3. Parameters are concatenated in their sorted order into a single string. For each parameter, the name is separated from the corresponding value by an = character (ASCII code 61), even if the value is empty. Each name-value pair is separated by an & character (ASCII code 38). For example:
4. a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t
If the absolute request URL is not available to the Service Provider (it is always available to the Consumer), it can be constructed by combining the scheme being used, the HTTP Hostheader, and the relative HTTP request URL. If the Host header is not available, the Service Provider SHOULD use the host name communicated to the Consumer in the documentation or other means. The Service Provider SHOULD document the form of URL used in the Signature Base String to avoid ambiguity due to URL normalization. Unless specified, URL scheme and authority MUST be lowercase and include the port number; http default port 80 and https default port 443 MUST be excluded. For example, the request:
HTTP://Example.com:80/resource?id=123
Is included in the Signature Base String as:
http://example.com/resource
9.2. HMAC-SHA1
The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104] where the Signature Base String is the text and the key is the concatenated values (each first encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an & character (ASCII code 38) even if empty.
9.3. RSA-SHA1
The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a verified way to the Service Provider, in a manner which is beyond the scope of this specification.
M the
9.4. PLAINTEXT
The PLAINTEXT method does not provide any security protection and SHOULD only be used over a secure channel such as HTTPS. It does not use the Signature Base String.
oauth_signature=djr9rjt0jd78jf88%26jjd999tj88uiths3
jjd99$tj88uiths3:
oauth_signature=djr9rjt0jd78jf88%26jjd99%2524tj88uiths 3
Empty:
oauth_signature=djr9rjt0jd78jf88%26
dpf43f3p2l4k3l03
Consumer Secret:
kd94hf93k423kf44
https://photos.example.net/request_token?oauth_consumer_key=dpf4
oauth_token=hh5s93j4hdidpola&oauth_token_secret=hdhd0244k9j7ao03
http://printer.example.com/request_token_ready?oauth_token=hh5s9 3j4hdidpola
The Service Provider checks the signature and replies with an Access Token in the body of the HTTP response:
oauth_token=nnch734d00sl2jdk&oauth_token_secret=pfkkdhi9sl3r4s00
dpf43f3p2l4k3l03
oauth_token:
nnch734d00sl2jdk
oauth_signature_method:
HMAC-SHA1
oauth_timestamp:
1191242096
oauth_nonce:
kllo9940pd9333jh
oauth_version:
1.0
file:
vacation.jpg
size:
original
The following inputs are used to generate the Signature Base String: 1. 2. 3.
SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2j dk&oauth_version=1.0&size=original
The Signature Base String is:
tR3+Ty81lMeYAr/Fid0kMTYa/WM=
http://photos.example.net/photos?file=vacation.jpg&size=original Authorization: OAuth realm="http://photos.example.net/", oauth_consumer_key="dpf43f3p2l4k3l03", oauth_token="nnch734d00sl2jdk", oauth_signature_method="HMAC-SHA1", oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D", oauth_timestamp="1191242096", oauth_nonce="kllo9940pd9333jh", oauth_version="1.0"
And if using query parameters:
While OAuth provides a mechanism for verifying the integrity of requests, it provides no guarantee of request confidentiality. Unless further precautions are taken, eavesdroppers will have full access to request content. Service Providers should carefully consider the kinds of data likely to be sent as part of such requests, and should employ transport-layer security mechanisms to protect sensitive resources.
If an attacker were to gain access to these secrets - or worse, to the Service Providers database of all such secrets - he or she would be able to perform any action on behalf of any User. Accordingly, it is critical that Service Providers protect these secrets from unauthorized access.
When implementing OAuth, Service Providers should consider the types of access Users may wish to grant Consumers, and should provide mechanisms to do so. Service Providers should also take care to ensure that Users understand the access they are granting, as well as any risks that may be involved.
Resource Exhaustion attacks are by no means specific to OAuth. However, OAuth implementors should be careful to consider the additional avenues of attack that OAuth exposes, and design their implementations accordingly. For example, entropy starvation typically results in either a complete denial of service while the system waits for new entropy or else in weak (easily guessable) secrets. When implementing OAuth, Service Providers should consider which of these presents a more serious risk for their application and design accordingly.
11. References
[NIST] National Institute of Standards and Technolog, NIST., NIST Brief Comments on Recent Cryptanalytic Attacks on Secure Hashing Functions and the Continued Security Provided by SHA-1.
[RFC2045] Freed, N. and N. Borenstein, Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, RFC 2045.
[RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, HMAC: Keyed-Hashing for Message Authentication, RFC 2104. [RFC2119] Bradner, B., Key words for use in RFCs to Indicate Requirement Levels, RFC 2119. [RFC2606] Eastlake, D. and A. Panitz, Reserved Top Level DNS Names, RFC 2606. [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, Hypertext Transfer Protocol HTTP/1.1, RFC 2616. [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., Leach, P., Luotonen, A., and L. Stewart, HTTP Authentication: Basic and Digest Access Authentication, RFC 2617. [RFC3447] Jonsson, J. and B. Kaliski, Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography; Specifications Version 2.1, RFC 3447. [RFC3629] Yergeau, F., UTF-8, a transformation format of Unicode and ISO 10646, RFC 3629. [RFC3986] Berners-Lee, T., Uniform Resource Identifiers (URI): Generic Syntax, RFC 3986. [SHA1] De Canniere, C. and C. Rechberger, Finding SHA-1 Characteristics: General Results and Applications.
Authors Address
OAuth Core Workgroup Email: spec@oauth.net