SlideShare a Scribd company logo
Open AuthenticationIntroductionDefinitionsProtocol WorkflowOAuth TokensSecurity ArchitectureOAuth and TwitterCoding OauthDemoTroubleshooting
OAuth?Oaths is an authorization standard for API’s that does away with logins and passwords to grant authorization to a third-party
Why OAuth?Every day a new websites are launched which tie services from different sites and offer you
OAuth DefinitionsService provider	The website or web-service where the restricted resources are locatedUser	User have ‘stuff’ they don’t want to make pubic on the service provider but they do want to share it with another siteConsumer	The name for the application trying access the users resourcesProtected Resources	The ‘stuff’ oauth protects and allow access.Tokens	Tokens are used instead of user credentials to access resources
OAuth : Protocol Workflow
Jane wants to share some of her vacation photos with her friends. Jane uses Faji, a photo sharing site, for sharing journey photos. She signs into her faji.com account, and uploads two photos which she marks private.	Using OAuth terminology		 Jane is the User 		Faji is the Service Provider. 		The 2 photos Jane uploaded are the Protected Resources.		OAuth Example
	Jane wants to share them with her grandmother. But grandma doesn’t have an internet connection so Jane plans to order prints and have them mailed to grandma. Being a responsible person, Jane uses Beppa, an environmentally friendly photo printing service.Using OAuth terminology, Beppa is the Consumer. Beppa must use OAuth to gain access to the photos in order to print them.
When Beppa added support for Faji photo import, a Beppa developer known in OAuth as a Consumer Developer obtained a Consumer Key and Consumer Secret from Faji to be used with Faji’s OAuth-enabled API.Using OAuth terminology, Consumer Key Consumer secret
Beppa requests from Faji a Request Token. At this point, the Request Token is not User-specific, and can be used by Beppa to gain User approval from Jane to access her private photos.Using OAuth terminology, Request Token
When Beppa receives the Request Token, it redirects Jane to the Faji OAuth User Authorization URL with the Request Token and asks Faji to redirect Jane back once approval has been granted to http://beppa.com/order.Using OAuth terminology, Oauth User Authorization URLCall Back URL
After successfully logging into Faji, Jane is asked to grant access to Beppa, the Consumer. Faji informs Jane of who is requesting access (in this case Beppa) and the type of access being granted. Jane can approve or deny access.
Jane waits for Beppa to present her with her photos fetched from her Faji account.
While Jane waits, Beppa uses the authorized Request Token and exchanges it for an Access Token. Request Tokens are only good for obtaining User approval, while Access Tokens are used to access Protected Resources, in this case Jane’s photos. In the first request, Beppa exchanges the Request Token for an Access Token and in the second (can be multiple requests, one for a list of photos, and a few more to get each photo) request gets the photos.Using OAuth terminology, Access Token
Jane is very impressed how Beppa grabbed her photos without asking for her username and password. She likes what she sees and place the print order.
OAuth
	TokensOAuth uses three types of credentialsClient credentials (consumer key and secret)Temporary credentials (request token and secret)Token credentials (access token and secret)
		Client CredentialsAllows server to authenticate serverAllows server to get information about the clientOauth_consumer_key	 Oauth_consumer_secret
Token CredentialsToken credentials are in place of username and passwordThe client uses token credentials to access resource owner protected resourceToken credentials are limited in scope and durationOauth_access_tokenOauth_access_secret
Temporary credentialsUsed to identify the authorization requestTo accommodate different clients like desktop, mobile etc.Add extra flexibility and securityOauth_tokenOauth_token_secret
	  OAuth  Security Architecture
 Signature and HashOAuth uses digital signatures instead of sending the full credentials (specifically, passwords) with each request. The sender uses a mathematical algorithm to calculate the signature of the request and includes it with the request.
Hash AlgorithmA common way to sign digital content is using a hash algorithm. Hashing is the process of taking data (of any size) and condensing it to a much smaller value (digest) in a fully reproducible (one-way) mannerThis means that using the same hash algorithm on the same data will always produce the same smaller valueHashing usually does not allow going from the smaller value back to the original.
Shared SecretBy itself, hashing does not verify the identity of the sender, only data integrity.In order to allow the recipient to verify that the request came from the claimed sender, the hash algorithm is combined with a shared secretIf both sides agree on some shared secret known only to them, they can add it to the content being hashed.
		Nonce(‘Number used Once’)What is missing is something to prevent requests intercepted by an unauthorized party, usually by sniffing the network, from being reused. This is known as a replay attack.Able to make the same sign request over and over again.To prevent compromised requests from being used again (replayed), OAuth uses a nonce and timestamp.By having a unique identifier for each request, the Service Provider is able to prevent requests from being used more than once
TimeStampUsing nonces can be very costly for Service Providers as they demand persistent storage of all nonce values received, ever.OAuth adds a timestamp value to each request which allows the Service Provider to only keep nonce values for a limited time.When a request comes in with a timestamp that is older than the retained time frame, it is rejected as the Service Provider no longer has nonces from that time period.
Signature MethodsOAuth defines 3 signature methods used to sign and verify requestsPLAINTEXTHMAC-SHA1RSA-SHA1	When signing requests, it is necessary to specify which signature method has been used to allow the recipient to reproduce the signature for verificationThe decision of which signature method to use depends on the security requirements of each application
Signature Base StringNot only must they both use the same algorithm and share secret, but they must sign the same content. This requires a consistent method for converting HTTP requests into a single string which is used as the signed content — the Signature Base String.. 
Getting the Request TokenBuilding a reqestToken request requires the following:HTTP Method,Request URI,oauth_callback,oauth_consumer_key,oauth_nonce,oauth_signature_method,oauth_timestamp oauth_version
Getting the Request TokenFirst build your string to signGetting the Request TokenFirst build your string to signThese parameters get sorted alphabetically, each value is URL escaped, and than concatenated into a single string.
Create your Authorization HTTP Header & and Issue the  requestNow we sign this string using our consumer secret and create an HTTP Authorization header. The signature should be placed in the oauth_signature valueGetting the Request token
Now we issue this request to the requestToken endpoint, and if all is sucessful,you will get something like the following URL encoded response:The oauth_token field is now your request token, and the oauth_token_secret will be used for signing your request for an access toen.oaut_callback_confirmed just gives you confirmation the we recognized your oauth_callback parameter You will want to “hold on” to oauth_token and oauth_token_secret until you have completed the access token stepEvaluate the Request Token
Now that we have a request token, we can build the url to authorize the user. we  will then redirect the user to this url so they can grant your application access.An authorization url is simply this end point:https://api.twitter.com/oauth/authorize with a query parameter tacked on called oauth_token.the value for this parameter is equal to the request token you received in the previous step.The user needs to land on this page within 5 minutes of your request take cycle. you should not pass an oauth_callback parameter to this page(you already did that in the request token step) Authorizing the memberBuild your Authorization URLhttps://api.twitter.com/oauth/authorize?oauth_token=O6npS44e8ZPQfVcYfHVTGXtnLVBQ4xn8Wu2eBFtPNQ
Send the user to Twitter Authorization PageThe user will then be sent to our authorization page. when completed the user will either be sent back to your oauth_callback URL or presented with a series of digits they will be instructed to hand-enter into your application(if you are performing out-of-band authentication)Authorizing the member
OAuth
OAuth
 Prepare your singing secretRegardless of whether you used out-of-band authentication or not, you will now be equipped with a request token an oauth_token_secret and an oauth_verfier.you are now going to exchange that request token for an access token, imbued with permission of the Twitter member to act on their behalfGetting an Access token
Getting the Access TokenFirst build your string to signFirst build your string to signThese parameters get sorted alphabetically, each value is URL escaped, and than concatenated into a single string.Getting the Access Token
Create your Authorization HTTP Header & and Issue the  requestNow we sign this string using our request token secret and create an HTTP Authorization header. The signature should be placed in the oauth_signature valueGetting the Access token
Now we issue this request to the aceessToken endpoint, and if all is sucessful,you will get something like the following URL encoded response:The oauth_token field is now your access token, and the auth_toke_secert will be used for signing all request on behalf of the member.You will want to “hold on” to oauth_token and oauth_token_secret until you have completed the access token stepEvaluate the Access Token
OAuth
Get Followers/ids
OAuth
	XML Response
Oauth is complicated, and there are a number of things that go wrong.Here are some tips.Every error response we send you will contain an xml body describing the error, including a timestamp representing server time. Some oauth-based requests will also return an OAUTH_PROBLEM http headerMake sure that your server’s system clock is in sync with oursOauth_callback should only be provided on the request token step.Oauth_verifier is required in the access Token.PUT & POST operations typically have xml content-types. your oauth library should exclude the request body in signature calculations as a result.For the access token step, remember that the request tokens oauth_token_secret must be used as part of your signing keyLikewise, for all resource requests, your access tokens oauth_token_secret must be used as part of your signing key.Troubleshooting
Referenceshttp://oauth.net/http://hueniverse.com/oauth/http://developer.yahoo.com/oauth/http://dev.twitter.com/pages/oauth_faq
OAuth
OAuth
OAuth

More Related Content

What's hot (19)

PDF
Implementing OAuth with PHP
Lorna Mitchell
 
PDF
OAuth2 primer
Manish Pandit
 
PPTX
(1) OAuth 2.0 Overview
anikristo
 
PDF
OAuth OpenID Connect
Léopold Gault
 
PDF
Security for oauth 2.0 - @topavankumarj
Pavan Kumar J
 
PDF
Implementing OAuth
leahculver
 
PPTX
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
PPTX
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
Good Dog Labs, Inc.
 
PPT
Oauth2.0
Yasmine Gaber
 
PPTX
An Introduction to OAuth 2
Aaron Parecki
 
PPTX
OAuth2 + API Security
Amila Paranawithana
 
PDF
Securing APIs with OAuth 2.0
Kai Hofstetter
 
PPTX
OAuth 2 Presentation
Mohamed Ahmed Abdullah
 
PDF
Using OAuth with PHP
David Ingram
 
PDF
OAuth big picture
Min Li
 
PDF
Ember Authentication and Authorization with Torii
Cory Forsyth
 
PDF
The Many Flavors of OAuth - Understand Everything About OAuth2
Khor SoonHin
 
PPTX
OAuth and Open-id
Parisa Moosavinezhad
 
PPTX
Oauth 2.0 security
vinoth kumar
 
Implementing OAuth with PHP
Lorna Mitchell
 
OAuth2 primer
Manish Pandit
 
(1) OAuth 2.0 Overview
anikristo
 
OAuth OpenID Connect
Léopold Gault
 
Security for oauth 2.0 - @topavankumarj
Pavan Kumar J
 
Implementing OAuth
leahculver
 
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
Good Dog Labs, Inc.
 
Oauth2.0
Yasmine Gaber
 
An Introduction to OAuth 2
Aaron Parecki
 
OAuth2 + API Security
Amila Paranawithana
 
Securing APIs with OAuth 2.0
Kai Hofstetter
 
OAuth 2 Presentation
Mohamed Ahmed Abdullah
 
Using OAuth with PHP
David Ingram
 
OAuth big picture
Min Li
 
Ember Authentication and Authorization with Torii
Cory Forsyth
 
The Many Flavors of OAuth - Understand Everything About OAuth2
Khor SoonHin
 
OAuth and Open-id
Parisa Moosavinezhad
 
Oauth 2.0 security
vinoth kumar
 

Similar to OAuth (20)

KEY
LinkedIn OAuth: Zero To Hero
Taylor Singletary
 
PPT
Silicon Valley Code Camp 2009: OAuth: What, Why and How
Manish Pandit
 
PDF
oauth-for-credentials-security-in-rest-api-access
idsecconf
 
PDF
O auth2.0 guide
Dilip Mohapatra
 
PPTX
O auth
faisalqau
 
PPTX
Api security
teodorcotruta
 
PDF
Secure Webservices
Matthias Käppler
 
PPTX
OAuth
Aslam Jarwar
 
PPTX
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
Nilanjan Roy
 
ODP
Securing your Web API with OAuth
Mohan Krishnan
 
ODP
Mohanraj - Securing Your Web Api With OAuth
fossmy
 
PPTX
OAuth [noddyCha]
noddycha
 
KEY
OAuth: demystified (hopefully)
Matt Gifford
 
PPTX
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
 
PDF
REST API Authentication Methods.pdf
Rubersy Ramos García
 
PPTX
OAuth 2
ChrisWood262
 
PDF
Stateless Auth using OAUTH2 & JWT
Mobiliya
 
PDF
.NET Core, ASP.NET Core Course, Session 19
Amin Mesbahi
 
LinkedIn OAuth: Zero To Hero
Taylor Singletary
 
Silicon Valley Code Camp 2009: OAuth: What, Why and How
Manish Pandit
 
oauth-for-credentials-security-in-rest-api-access
idsecconf
 
O auth2.0 guide
Dilip Mohapatra
 
O auth
faisalqau
 
Api security
teodorcotruta
 
Secure Webservices
Matthias Käppler
 
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
Nilanjan Roy
 
Securing your Web API with OAuth
Mohan Krishnan
 
Mohanraj - Securing Your Web Api With OAuth
fossmy
 
OAuth [noddyCha]
noddycha
 
OAuth: demystified (hopefully)
Matt Gifford
 
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
 
REST API Authentication Methods.pdf
Rubersy Ramos García
 
OAuth 2
ChrisWood262
 
Stateless Auth using OAUTH2 & JWT
Mobiliya
 
.NET Core, ASP.NET Core Course, Session 19
Amin Mesbahi
 
Ad

OAuth

  • 1. Open AuthenticationIntroductionDefinitionsProtocol WorkflowOAuth TokensSecurity ArchitectureOAuth and TwitterCoding OauthDemoTroubleshooting
  • 2. OAuth?Oaths is an authorization standard for API’s that does away with logins and passwords to grant authorization to a third-party
  • 3. Why OAuth?Every day a new websites are launched which tie services from different sites and offer you
  • 4. OAuth DefinitionsService provider The website or web-service where the restricted resources are locatedUser User have ‘stuff’ they don’t want to make pubic on the service provider but they do want to share it with another siteConsumer The name for the application trying access the users resourcesProtected Resources The ‘stuff’ oauth protects and allow access.Tokens Tokens are used instead of user credentials to access resources
  • 6. Jane wants to share some of her vacation photos with her friends. Jane uses Faji, a photo sharing site, for sharing journey photos. She signs into her faji.com account, and uploads two photos which she marks private. Using OAuth terminology Jane is the User Faji is the Service Provider. The 2 photos Jane uploaded are the Protected Resources. OAuth Example
  • 7. Jane wants to share them with her grandmother. But grandma doesn’t have an internet connection so Jane plans to order prints and have them mailed to grandma. Being a responsible person, Jane uses Beppa, an environmentally friendly photo printing service.Using OAuth terminology, Beppa is the Consumer. Beppa must use OAuth to gain access to the photos in order to print them.
  • 8. When Beppa added support for Faji photo import, a Beppa developer known in OAuth as a Consumer Developer obtained a Consumer Key and Consumer Secret from Faji to be used with Faji’s OAuth-enabled API.Using OAuth terminology, Consumer Key Consumer secret
  • 9. Beppa requests from Faji a Request Token. At this point, the Request Token is not User-specific, and can be used by Beppa to gain User approval from Jane to access her private photos.Using OAuth terminology, Request Token
  • 10. When Beppa receives the Request Token, it redirects Jane to the Faji OAuth User Authorization URL with the Request Token and asks Faji to redirect Jane back once approval has been granted to http://beppa.com/order.Using OAuth terminology, Oauth User Authorization URLCall Back URL
  • 11. After successfully logging into Faji, Jane is asked to grant access to Beppa, the Consumer. Faji informs Jane of who is requesting access (in this case Beppa) and the type of access being granted. Jane can approve or deny access.
  • 12. Jane waits for Beppa to present her with her photos fetched from her Faji account.
  • 13. While Jane waits, Beppa uses the authorized Request Token and exchanges it for an Access Token. Request Tokens are only good for obtaining User approval, while Access Tokens are used to access Protected Resources, in this case Jane’s photos. In the first request, Beppa exchanges the Request Token for an Access Token and in the second (can be multiple requests, one for a list of photos, and a few more to get each photo) request gets the photos.Using OAuth terminology, Access Token
  • 14. Jane is very impressed how Beppa grabbed her photos without asking for her username and password. She likes what she sees and place the print order.
  • 16. TokensOAuth uses three types of credentialsClient credentials (consumer key and secret)Temporary credentials (request token and secret)Token credentials (access token and secret)
  • 17. Client CredentialsAllows server to authenticate serverAllows server to get information about the clientOauth_consumer_key Oauth_consumer_secret
  • 18. Token CredentialsToken credentials are in place of username and passwordThe client uses token credentials to access resource owner protected resourceToken credentials are limited in scope and durationOauth_access_tokenOauth_access_secret
  • 19. Temporary credentialsUsed to identify the authorization requestTo accommodate different clients like desktop, mobile etc.Add extra flexibility and securityOauth_tokenOauth_token_secret
  • 20. OAuth Security Architecture
  • 21. Signature and HashOAuth uses digital signatures instead of sending the full credentials (specifically, passwords) with each request. The sender uses a mathematical algorithm to calculate the signature of the request and includes it with the request.
  • 22. Hash AlgorithmA common way to sign digital content is using a hash algorithm. Hashing is the process of taking data (of any size) and condensing it to a much smaller value (digest) in a fully reproducible (one-way) mannerThis means that using the same hash algorithm on the same data will always produce the same smaller valueHashing usually does not allow going from the smaller value back to the original.
  • 23. Shared SecretBy itself, hashing does not verify the identity of the sender, only data integrity.In order to allow the recipient to verify that the request came from the claimed sender, the hash algorithm is combined with a shared secretIf both sides agree on some shared secret known only to them, they can add it to the content being hashed.
  • 24. Nonce(‘Number used Once’)What is missing is something to prevent requests intercepted by an unauthorized party, usually by sniffing the network, from being reused. This is known as a replay attack.Able to make the same sign request over and over again.To prevent compromised requests from being used again (replayed), OAuth uses a nonce and timestamp.By having a unique identifier for each request, the Service Provider is able to prevent requests from being used more than once
  • 25. TimeStampUsing nonces can be very costly for Service Providers as they demand persistent storage of all nonce values received, ever.OAuth adds a timestamp value to each request which allows the Service Provider to only keep nonce values for a limited time.When a request comes in with a timestamp that is older than the retained time frame, it is rejected as the Service Provider no longer has nonces from that time period.
  • 26. Signature MethodsOAuth defines 3 signature methods used to sign and verify requestsPLAINTEXTHMAC-SHA1RSA-SHA1 When signing requests, it is necessary to specify which signature method has been used to allow the recipient to reproduce the signature for verificationThe decision of which signature method to use depends on the security requirements of each application
  • 27. Signature Base StringNot only must they both use the same algorithm and share secret, but they must sign the same content. This requires a consistent method for converting HTTP requests into a single string which is used as the signed content — the Signature Base String.. 
  • 28. Getting the Request TokenBuilding a reqestToken request requires the following:HTTP Method,Request URI,oauth_callback,oauth_consumer_key,oauth_nonce,oauth_signature_method,oauth_timestamp oauth_version
  • 29. Getting the Request TokenFirst build your string to signGetting the Request TokenFirst build your string to signThese parameters get sorted alphabetically, each value is URL escaped, and than concatenated into a single string.
  • 30. Create your Authorization HTTP Header & and Issue the requestNow we sign this string using our consumer secret and create an HTTP Authorization header. The signature should be placed in the oauth_signature valueGetting the Request token
  • 31. Now we issue this request to the requestToken endpoint, and if all is sucessful,you will get something like the following URL encoded response:The oauth_token field is now your request token, and the oauth_token_secret will be used for signing your request for an access toen.oaut_callback_confirmed just gives you confirmation the we recognized your oauth_callback parameter You will want to “hold on” to oauth_token and oauth_token_secret until you have completed the access token stepEvaluate the Request Token
  • 32. Now that we have a request token, we can build the url to authorize the user. we will then redirect the user to this url so they can grant your application access.An authorization url is simply this end point:https://api.twitter.com/oauth/authorize with a query parameter tacked on called oauth_token.the value for this parameter is equal to the request token you received in the previous step.The user needs to land on this page within 5 minutes of your request take cycle. you should not pass an oauth_callback parameter to this page(you already did that in the request token step) Authorizing the memberBuild your Authorization URLhttps://api.twitter.com/oauth/authorize?oauth_token=O6npS44e8ZPQfVcYfHVTGXtnLVBQ4xn8Wu2eBFtPNQ
  • 33. Send the user to Twitter Authorization PageThe user will then be sent to our authorization page. when completed the user will either be sent back to your oauth_callback URL or presented with a series of digits they will be instructed to hand-enter into your application(if you are performing out-of-band authentication)Authorizing the member
  • 36. Prepare your singing secretRegardless of whether you used out-of-band authentication or not, you will now be equipped with a request token an oauth_token_secret and an oauth_verfier.you are now going to exchange that request token for an access token, imbued with permission of the Twitter member to act on their behalfGetting an Access token
  • 37. Getting the Access TokenFirst build your string to signFirst build your string to signThese parameters get sorted alphabetically, each value is URL escaped, and than concatenated into a single string.Getting the Access Token
  • 38. Create your Authorization HTTP Header & and Issue the requestNow we sign this string using our request token secret and create an HTTP Authorization header. The signature should be placed in the oauth_signature valueGetting the Access token
  • 39. Now we issue this request to the aceessToken endpoint, and if all is sucessful,you will get something like the following URL encoded response:The oauth_token field is now your access token, and the auth_toke_secert will be used for signing all request on behalf of the member.You will want to “hold on” to oauth_token and oauth_token_secret until you have completed the access token stepEvaluate the Access Token
  • 44. Oauth is complicated, and there are a number of things that go wrong.Here are some tips.Every error response we send you will contain an xml body describing the error, including a timestamp representing server time. Some oauth-based requests will also return an OAUTH_PROBLEM http headerMake sure that your server’s system clock is in sync with oursOauth_callback should only be provided on the request token step.Oauth_verifier is required in the access Token.PUT & POST operations typically have xml content-types. your oauth library should exclude the request body in signature calculations as a result.For the access token step, remember that the request tokens oauth_token_secret must be used as part of your signing keyLikewise, for all resource requests, your access tokens oauth_token_secret must be used as part of your signing key.Troubleshooting