• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
The Current State of OAuth 2
 

The Current State of OAuth 2

on

  • 11,618 views

If you've ever written any code to authenticate wtih Twitter, you may have been confused by all the signature methods and base strings. You'll be happy to know that OAuth 2 has vastly simplified the ...

If you've ever written any code to authenticate wtih Twitter, you may have been confused by all the signature methods and base strings. You'll be happy to know that OAuth 2 has vastly simplified the process, but at what cost?

This talk will give an overview of the OAuth 2 spec, starting with the various options the standard gives to developers for building web apps and native apps. We'll look at what the end user sees, work our way to what developers using an OAuth 2 API deal with, and we’ll end up at what developers of OAuth-2-compliant APIs will need to know to successfully implement the standard.

Many large providers have recently deployed APIs using OAuth 2, including Facebook, Foursquare, Google, and more. But since OAuth 2 is technically still a "draft," many aspects of the spec change from month to month and it's sometimes hard to keep up. We'll cover the commonalities and differences between some of the major providers and draft versions. The security implications of some of the changes between versions 1 and 2 will be covered, along with recommendations for best practices. You'll also get a glimpse of the debates currently raging on the internal OAuth 2 mailing list.

Presented at Open Source Bridge 2011

http://opensourcebridge.org/sessions/686

Current list of OAuth 2 Providers
http://aaronparecki.com/The_Current_State_of_OAuth_2

Statistics

Views

Total Views
11,618
Views on SlideShare
9,572
Embed Views
2,046

Actions

Likes
18
Downloads
248
Comments
0

12 Embeds 2,046

http://ianloic.com 1134
http://aaronparecki.com 768
url_unknown 54
http://pk2.dev 35
http://mikenovember.com 27
http://ian.wordpress.com 19
http://safe.tumblr.com 3
http://pk.dev 2
http://translate.googleusercontent.com 1
http://www.newsblur.com 1
https://twimg0-a.akamaihd.net 1
http://sebastian-werner.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    The Current State of OAuth 2 The Current State of OAuth 2 Presentation Transcript

    • The Current Stateof OAuth 2Aaron Parecki • @aaronpkOpen Source Bridge • Portland, June 2011
    • A Brief Historyaaron.pk/oauth2 @aaronpk
    • Before OAuth aka the Dark Ages If a third party wanted access to an account, you’d give them your password.aaron.pk/oauth2 @aaronpk
    • Before OAuth 1.0 Many sites implemented things similar to OAuth 1.0, with slight differences between them. ¡  Flickr: “FlickrAuth” frobs and tokens ¡  Google: “AuthSub” ¡  Facebook: requests signed with MD5 hashesaaron.pk/oauth2 @aaronpk
    • OAuth 1.0aaron.pk/oauth2 @aaronpk
    • OAuth 1.0 Signatures The signature base string is often the most difficult part of OAuth for newcomers to construct. The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed, complete with path (but not query parameters), followed by an ampersand ("&"). Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored), including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and oauth_nonce="QP70eNmVz8jvdPevU3oJD2AfF7R7o then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for oauth_callback="http%3A%2F dC2XJcn4XlZJqk", each %2Flocalhost%3A3005%2Fthe_dance parameter are URL encoded in isolation. Instead of using the %2Fprocess_callback%3Fservice_provider_id equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then %3D11", oauth_signature_method="HMAC-SHA1", joined by the URL-escaped ampersand sign, "%26". oauth_timestamp="1272323042", oauth_consumer_key="GDdmIQH6jhtmLUypg82g", oauth_signature="8wUi7m5HFQy76nowoCThusfgB %2BQ%3D", oauth_version="1.0"aaron.pk/oauth2 @aaronpk
    • OAuth 2: signatures replaced by https HMACaaron.pk/oauth2 @aaronpk
    • Some Current Implementers
    • Facebook’s OAuth FlowSource: https://developers.facebook.com/docs/authentication/ @aaronpk
    • aaron.pk/oauth2 @aaronpk
    • aaron.pk/oauth2 @aaronpk
    • aaron.pk/oauth2 @aaronpk
    • The Spec Read it.It’s not that bad, I promise. aaron.pk/oauth2-10
    • But which draft? There are 16!!aaron.pk/oauth2 @aaronpk
    • Currently Implemented DraftsProvider Draft ReferenceFoursquare -10 http://aaron.pk/2YS http://code.google.com/apis/accounts/docs/Google -10 OAuth2.htmlGowalla -8 http://gowalla.com/api/docs/oauth https://developers.facebook.com/docs/Facebook -10 (ish) authentication/oauth2_updates/Windows Live -10 http://aaron.pk/2YVSalesforce -10 http://aaron.pk/2YWGithub -07 http://develop.github.com/p/oauth.htmlGeoloqi -10 http://geoloqi.org/API @aaronpk
    • Abstract Protocol Flowaaron.pk/oauth2 @aaronpk
    • Definitionsaaron.pk/oauth2 @aaronpk
    • 1. Authorizationaaron.pk/oauth2 @aaronpk
    • Create a “Log In” linkLink to:https://geoloqi.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=REDIRECT_URIaaron.pk/oauth2 @aaronpk
    • Send the user to the auth pagehttps://geoloqi.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=REDIRECT_URIaaron.pk/oauth2 @aaronpk
    • On success, user is redirectedback to your site with auth codehttps://example.com/auth?code=AUTH_CODE_HEREOn error, user is redirected backto your site with error codehttps://example.com/auth?error=access_deniedaaron.pk/oauth2 @aaronpk
    • Exchange auth code for anaccess tokenYour server makes the following requestPOST https://api.geoloqi.com/1/oauth/tokenPost Body:grant_type=authorization_code&code=CODE_FROM_QUERY_STRING&redirect_uri=REDIRECT_URI&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRETaaron.pk/oauth2 @aaronpk
    • Exchange auth code for anaccess token (response)Your server gets a response like the following{ "access_token":"RsT5OjbzRn430zqMLgV3Ia", "expires_in":3600, "refresh_token":"e1qoXg7Ik2RRua48lXIV"}or if there was an error{ "error":"invalid_request"}aaron.pk/oauth2 @aaronpk
    • 2. Accessing Resourcesaaron.pk/oauth2 @aaronpk
    • Use the access token tomake requestsNow you can make requests using the access token.GET https://api.geoloqi.com/1/account/profileAuthorization: OAuth RsT5OjbzRn430zqMLgV3IaAccess token can be in an HTTP header or a querystring parameterhttps://api.geoloqi.com/1/account/profile?oauth_token=RsT5OjbzRn430zqMLgV3Iaaaron.pk/oauth2 @aaronpk
    • Eventually the access tokenwill expireWhen you make a request with an expired token,you will get this response{ "error":"expired_token"}Now you need to get a new access token!aaron.pk/oauth2 @aaronpk
    • Get a new access tokenusing a refresh tokenYour server makes the following requestPOST https://api.geoloqi.com/1/oauth/tokengrant_type=refresh_token&reresh_token=e1qoXg7Ik2RRua48lXIV&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRETYour server gets a similar response as the original call tooauth/token with new tokens.{ "access_token":"RsT5OjbzRn430zqMLgV3Ia", "expires_in":3600, "refresh_token":"e1qoXg7Ik2RRua48lXIV"}aaron.pk/oauth2 @aaronpk
    • OAuth 2 ClientsClient libraries should handle refreshing the tokenautomatically behind the scenes.aaron.pk/oauth2 @aaronpk
    • Authorization Methods¡  Auth Code¡  Refresh Token¡  PasswordDraft 10 also has¡  AssertionDraft 16 also has¡  Implicit (for browser-based apps)¡  Extensions (for defining custom grant types)aaron.pk/oauth2 @aaronpk
    • Password Grant Type Suitable for mobile or native desktop apps where a web browser flow would be awkward. This breaks the fundamental benefit of OAuth (not giving your password to third parties), so should probably be limited to your own apps.aaron.pk/oauth2
    • Password GrantYour server makes the following requestPOST https://api.geoloqi.com/1/oauth/tokengrant_type=password&username=USERNAME&password=PASSWORD&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRETYour server gets a similar response as the original call tooauth/token with new tokens.{ "access_token":"RsT5OjbzRn430zqMLgV3Ia", "expires_in":3600, "refresh_token":"e1qoXg7Ik2RRua48lXIV"}aaron.pk/oauth2 @aaronpk
    • Implicit Grant (-16)For clients who can’t store a client secret in a secureway, typically Javascript-based apps.No concept of refresh tokens, and auth codes arenot used either.The redirection back to your app will include anaccess token in the URL fragment.https://example.com/auth#access_token=FJQbwq9aaron.pk/oauth2 @aaronpk
    • Implementing an OAuth Server
    • Implementing an OAuth Server ¡  Find a server library already written ¡  Choose a draft to implement ¡  Draft 10 – more likely that your users will be familiar with it ¡  Latest Draft – if you want to show you’re bleeding edge ;) ¡  Read the spec of your chosen draft, in its entirety. ¡  These people didn’t write the spec for you to ignore it. ¡  Each word is chosen carefully. ¡  Ultimately, each implementation is somewhat different, since in many cases the spec says SHOULD and leaves the choice up to the implementer.aaron.pk/oauth2 @aaronpk
    • Limiting Access to Third Partiesaaron.pk/oauth2 @aaronpk
    • Proposed New UI for Twitterby Ben Wardhttp://blog.benward.me/post/968515729
    • OAuth 2 scope ¡  Created to limit access to the third party. ¡  The scope of the access request expressed as a list of space-delimited, case sensitive strings. ¡  The value is defined by the authorization server. ¡  If the value contains multiple space-delimited strings, their order does not matter, and each string adds an additional access range to the requested scope.aaron.pk/oauth2 @aaronpk
    • OAuth 2 scope on Facebook https://www.facebook.com/dialog/oauth? client_id=YOUR_APP_ID&redirect_uri=YOUR_URL &scope=email,read_streamaaron.pk/oauth2 @aaronpk
    • OAuth 2 scope on Github https://github.com/login/oauth/authorize? client_id=...&scope=user,public_repoaaron.pk/oauth2 @aaronpk
    • OAuth 2 scope on your service ¡  Think about what scopes you might offer ¡  Don’t over-complicate it for your users ¡  Read vs write is a good startaaron.pk/oauth2 @aaronpk
    • Join the Mailing List!¡  https://www.ietf.org/mailman/listinfo/oauth¡  People talk about OAuth¡  Keep up to date on changes¡  People argue about OAuth¡  It’s fun!aaron.pk/oauth2 @aaronpk
    • Raging Debates¡  March and April 2011¡  Summary Email: http://aaron.pk/2YXThe question:Require or recommend usingTLS on the auth redirect?aaron.pk/oauth2 @aaronpk
    • Require TLS on auth redirect? ¡  When the auth server redirects back to the client with an auth code in the query string, an MITM attack is possible unless the client’s server is using https ¡  Problem: It is not always practical to run your site with https ¡  Certificates aren’t the only barrier ¡  Loading off-site content (banner ads, site statistics, etc) would also have to use https, otherwise the visitor sees terrible warning messages ¡  https is often slower, since browsers don’t like to cache thingsaaron.pk/oauth2 @aaronpk
    • Require TLS on auth redirect? ¡  Many large providers (Google, Facebook) won’t require it, because they don’t want to force developers to have SSL certificates (would lead to lower adoption) ¡  Many enterprise users do want to require it, because they are more concerned with security than high adoption of their API ¡  The question is whether the spec should require it or just recommend, if it does, then Google/Facebook/others won’t be compliantaaron.pk/oauth2 @aaronpk
    • Require TLS on auth redirect?“This debate is just like talking about highway safety. Weknow how to make driving 100% safe. Everyone will drivetanks at no faster than 10mph, or alternatively, no one willdrive and we’ll all climb on conveyor belts to get anywhere(each bubble wrapped and put into a medically inducedcoma to make sure we don’t move around). But in the realworld, practical considerations trump 100% guarantees.By just offering services online you put users at some risk. Ifyou want 100% safe online banking, just don’t offer any.”Excerpt of an email to the oauth-wg list from Eran Hammer-Lahav: http://aaron.pk/2Ya
    • draft-ietf-oauth-v2-16aaron.pk/oauth2 @aaronpk
    • Moving access into separate specs Bearer tokens vs MAC authenticationaaron.pk/oauth2 @aaronpk
    • Draft 10GET /1/profile HTTP/1.1Host: api.example.comAuthorization: OAuth vF9dft4qmTDraft 16GET /1/profile HTTP/1.1Host: api.example.comAuthorization: Bearer vF9dft4qmTorGET /1/profile HTTP/1.1Host: api.example.comAuthorization: MAC id="jd93dh9dh39D", nonce="273156:di3hvdf8", bodyhash="k9kbtCIyI3/FEfpS/oIDjk6k=", mac="W7bdMZbv9UWOTadASIQHagZyirA="http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-5http://tools.ietf.org/html/draft-ietf-oauth-v2-bearer-04#section-2 @aaronpkhttp://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-00#section-3
    • Security Recommendationsfor Clients Using Bearer Tokens¡  Safeguard bearer tokens¡  Validate SSL certificates¡  Always use https¡  Don’t store bearer tokens in plaintext cookies¡  Issue short-lived bearer tokens¡  Don’t pass bearer tokens in page URLsaaron.pk/oauth2 @aaronpk
    • http://code.flickr.com/blog/2011/06/21/flickr-now-supports-oauth-1-0a/ Currently, we only support OAuth 1.0a, but we have plans to eventually support OAuth 2.0. The decision was based on the fact that OAuth 2.0 is still an evolving definition that is rapidly changing.
    • Nothing is perfect. Everything changes. Go build stuff.aaron.pk/oauth2 @aaronpk
    • Thanks. Aaron Parecki @aaronpk aaronparecki.comgithub.com/aaronpk