SlideShare a Scribd company logo
1 
* E-mails: sales@nexright.com
OAuthisanopenprotocolstandardforWebAPIauthorization.OAuthprovidesamethodforuserstograntthird-partyaccesstotheirresourceswithoutsharingtheirpasswords. 
What is OAuth? 
OAuth is an open protocol standard for Web API authorization 
2 
Nasrin Sohrabi
Why using OAuth2.0 ? 
one way to address REST security issues is with the open source protocol OAuth 
1) Lack of standards and support of RESTfulAPI 
Askingauserfortheirpasswordhasanumberofside-effectsuchas: 
Trust:ausermaynottrustprovidingtheirpasswordtoyourapplication. 
Expandedaccessandrisks:Whentheuserprovidestheirpasswordtoyourapplication,yougetaccesstonotonlythedatayourapplicationneeds,butallotherdataintheuser’saccount.Theapplicationhasanobligationtoitsuserstosecurelystorethesepasswordsandpreventthemfromleaking.Manydevelopersdonotwanttheriskexposureofhavingthisadditionalresponsibility. 
Decreasedusersensitivitytophishing:Eveniftheuseriscomfortableprovidingtheirpasswordtoyourapplication,makingtheusercomfortabledoingthisaroundtheWebcanhavenegativelong-termeffects,suchasmakingphishingscamsmoreeffective. 
Limitedreliability:Whenauserchangestheirpassword,yourapplicationnolongerhasaccesstotheirdata. 
Revocationchallenges:Theonlywayausercanrevokeaccesstoyourapplicationisbychangingtheirpassword,whichalsorevokesaccesstoallotherapps. 
Passwordsbecomerequired:WhenanAPIprovidersupportsfederatedauthenticationmechanismssuchasOpenIDorSAML,usersmaynothavepasswordsontheiraccounts.ThismakesitimpossibleforthoseuserstouseapplicationspoweredbytheAPI. 
Difficultyimplementingstrongerauthentication:IfanAPIproviderrequirespasswordsforAPIauthentication,itbecomeschallengingtoimproveaccountsecuritywithtechnologieslikeCAPTCHAsormultifactorauthentication(suchasone-timepasswordtokens). 
2)PasswordAnti-Pattern 
Within move towards SaaS–trend towards API access to data/services to supplement/replace browser access. 
Clear trend for these APIs is towards REST. 
3) Cloud APIs 
4) Native Mobile Applications 
3 
Nasrin Sohrabi
Client Application 
User Agent 
How does OAuth2.0 work? 
OAuth 2.0 protocol uses a number of actors to achieve the main tasks of getting, validating, and using an access token 
4 
Nasrin Sohrabi 
Authorization Server 
Resource Server 
Resource Owner
The main Actors are: 
User or Resource Owner 
Theactualenduser,responsibleforauthenticationandtoprovideconsenttosharetheirresourceswiththerequestingclient 
User Agent 
Theuser’sbrowser.usedforredirect‐basedflowswheretheusermustauthenticateandoptionallyprovideconsenttosharetheirresources. 
Client 
Authorization Server (AS) 
Resource Server (RS) 
The Client Application that is requesting an access token on behalf of the end user. 
A server capable of issuing tokens, obtaining authorization, and authenticating resource owners. 
The target application or API that provides the requested resources. This actor will validate an access token to provide authorization for theaction. (The server hosting protected resources) 
5 
Nasrin Sohrabi
Oauth2.0 provides four standard grant typesandan extension grant type that can beusedto customize the authentication and authorization process depending on the application requirements: 
Server Side Web Application Flow (Authorization Code Flow) 
Client Side Web Application Flow (Implicit Grant Flow) 
Resource Owner Password Flow 
Client Credentials 
Extension Grant 
6 
Nasrin Sohrabi 
OAuth2.0 Grant Types
Authorization Code 
Resource Owner Cridential 
Implicit 
Client Credentials 
Used for most Web and mobile application scenarios that want to call REST Web services. uses the user agent to transport an intermediate code, which is then exchanged for the OAuth2 tokens. 
Scenariowhereclientisnotabletosafelyhidetheclientsecret(e.g. clientsideJavaScriptapplication).UsestheuseragenttotransportTheOAuth2tokens. 
Whenapplicationneedstocontroltheloginform(e.g.NativeMobileapp). Exchangesausername/passwordcombinationfortheOAuth2tokens. 
Whenauserisnotinvolved.AccesstokenonlyrequiredforaservicetocallaRESTwebservice.ExchangestheclientcredentialsforanOAuth2Accesstoken. 
Extension Grant Type 
Used To Extend The Oauth2.0 Grant Types For specific Scenarios (e.g. the SAML bearer extension grant). 
7 
Nasrin Sohrabi
Some of the important terminologies that use during work with OAuth: 
Client key: 
Client Secret: 
Authorization 
Code: 
Access Token: 
Refresh Token: 
AvalueusedbytheconsumertoidentifyitselftotheServiceProvider. 
A secret used by the consumer to establish ownership of the consumer key. 
Avalueusedbytheconsumertoobtainauthorizationfromtheuser,andexchangedforanAccessToken 
Atokenusedbytheclienttomakeauthenticatedrequestsonbehalfoftheresourceowner. 
Atokenusedbytheclienttoobtainanewaccesstokenwithouthavingtoinvolvetheresourceowner. 
8 
Nasrin Sohrabi
9 
AS Enpoint 
Authorization Endpoints: 
• used, via user-agent redirection, to authenticate and obtain authorization from the resource owner. 
• End user on the front channel. 
Token Endpoints 
• Used to exchange an authorization grant for an access token. 
• Client on the back channel. 
Client Endpoint 
Redirection URI 
• After completing its interaction with the resource owner, the AS directs the resource owner's user-agent back to the client at the client’s redirection URI. 
• Front channel callback. 
Nasrin Sohrabi 
Endpoints
The application developer will be responsible for the user-facing Elements Of theprocess. 
They will needto authenticate the user and interface with the back-end APIs. There are three main actions an application developer needs to handle to implement OAuth2: 1) Get an access token. 2) Use an access token. 3) Refresh an access token(optional). 
10 
Nasrin Sohrabi 
In the following slides, I will explained how to get an OAuth access token from PingFederate infrastructure, based on Authorization code grant type.
Authorizationgrantisaclientredirectbasedflow.Inthisscenario,theuserwillberedirectedtothePingFederateauthorizationendpointviatheuseragent(i.e.webbrowser).ThisuseragentwillbeUsedtoauthenticatetheenduserandallowthemtograntaccesstotheclient.Oncetheuserhasbeenauthorized,anintermediatecodewillbegrantedbytheauthorizationserverandreturnedTotheclientapplicationviatheuseragent.Lastly,theclientwillswapthiscodeforanOauthaccesstoken. 
11 
Nasrin Sohrabi
Authorization code grant process 
Request Authorization 
Obtain User Authorization 
Exchange Code for Access Token 
Validate and Perform Actions 
There are 4 main steps to the authorization code grant type process: 
The client redirects the user to the Authorization Endpoint (Ping Federate)to request an authorization code. 
The Resource Owner (User) grants permissions for the 
client to access resource data. The authorization code is given to the client (callback 
from auth. server). 
The authorization code is exchanged for an access token given to the client by the Token Endpoint (Ping Federate) . 
The Resource Server validates the Access Token and gives access to the client if validation is successful 
12 
Nasrin Sohrabi
Client 
Authorization EndPoint 
(PingFederate) 
Token EndPoint 
(PingFederate) 
Resource Server 
Grant Authorization Code 
Direct user To Resource Provider 
User Authentication 
Grant permissions 
Request Authorization Code 
Request Access Token 
Grant Access Token 
Direct users To the client with authcode 
1 
Obtain Authorization code 
2 
Obtain Authorization to use code 
Access Protected Resources 
Validate Token 
Use Access Token 
3 
Exchange Code for Access Token 
4 
Client Uses Resources 
13 
Nasrin Sohrabi
Phases in detail: 
Theclientrequestsresourcedata,whichredirectstheuserthroughanauthorizationprocessinordertoobtainanauthorizationcode.AftertheuserauthenticatesandauthorizesaccessatPingFederate,acallback(viaanHTTP 
redirect)willbemadebacktotheclientapplicationwiththeauthorizationcodeinthequeryStringlike(https://localhost:9031/OAuthPlayground/case1callback.jsp?state=&code=5qJvl5hWL20KS6ZKzQ- eZAYBjF0coxe3YhPaAhM2).Now,theclientsitesendsanhttprequesttoexchangetheauthorizationcodeobtainedinthecallbackforthedesiredtokens(typicallyanaccesstokenandarefreshtoken).TheprocessofexchangingrequirestheclienttocommunicatewiththePingFederateTokenEndpoint(https://<pf>/as/token.oauth2)withthefollowingparameters:client_id,granttype=authorizationcodeandtheauthorizationcodereceivedinthepreviousstep.Forsecurityreasonsthecodecanonlybeusedonce.TheresultisanHTTP200responsetotheclientindicatingsuccessfromtheTokenendpoint.TheresponseisreturnedformattedinJSON(JavaScriptObjectotation) containingtheOAuthAccessToken.Theclientcannowusetheaccesstokentoperformactionsusingthedataitrequiresontheresourceserverbeforethetokenisexpired.TheresourceserverreceivestheaccesstokenandperformsavalidationcheckwiththeTokenendpointtomakesurethetokenisvalidbeforeperformingtherequiredaction. 
14 
Nasrin Sohrabi
Authorization Endpoint 
Web Client 
(Our application) 
Browser 
Token Endpoint 
1 
4 
3 
2 
1 
Request query string includes the OAuth client ID, response type and requested scopes and redirect uri. 
Request 
Redirect to Authorization Server 
3 
5 
15 
Nasrin Sohrabi 
PingFederate Server
WebapplicationredirectsusertoAuthorizationServer(AS),whichisPingFederate,atitsauthorizationendpoint(https://<pf>/as/authorization.oauth2).RequestquerystringincludestheOAuthclientID,responsetype(inthiscaseauthorizationcode)andrequestedscopesandstate. 
UserauthenticatestoASviaIdPadapterorIdPconnection.Afterauthentication,userseesconfirmationpagewithrequestedscopesfromtheOAuthclientredirect,andclicks"Approve” 
ASredirectsuserbacktoclientsitewithAuthorizationCodeinquerystring. 
WebsiteresolvesAuthorizationCodetoanOAuthtoken(AccessToken[andRefreshToken])viaAPIcalltotheASTokenEndpoint(https://<pf>/as/token.oauth2) 
TheresultisanHTTP200responsetotheclientindicatingsuccessfromtheTokenEndpoint.TheresponseisreturnedformattedinJSON(JavaScriptObjectNotation) 
containingtheOAuthAccessToken 
2 
4 
5 
1 
3 
16 
Nasrin Sohrabi
An example of authorization request from user and retrieve authorization code 
https://localhost:9031/as/authorization.oauth2? 
client_id=ac_client& 
response_type=code& 
scope=edit& 
redirect_uri=sample%3A%2F%2Foauth2%2Fcode%2Fcb 
17 
Nasrin Sohrabi
18 
References: 
1. Ryan Boyd, Getting Started with OAuth2.0, published by O’REILLY, February 2012. 
2. OAuth2 Developers Guide, PingIdentity, 07/09/2014. 
3. PingFederate Administrator’s Manual, June 27, 2014 . 
4. Ryan Boyd, OAuth2 Identity and Data Access, 2012. 
5. John DaSilva, Ping Identity and OAuth and OpenIDConnect In Action with PingFederate Hands-On, 7/8/2013. 
6. OAuth2 Tutorial, Ping Identity, July 2014. 
Nasrin Sohrabi
19 
Nasrin Sohrabi

More Related Content

PPTX
An introduction to OAuth 2
PPTX
Best Practices in Building an API Security Ecosystem
PDF
Demystifying OAuth 2.0
PDF
Introduction to OAuth2.0
PPT
Securing RESTful API
ODP
OAuth2 - Introduction
PPTX
OAuth2 & OpenID Connect
PDF
OAuth2 primer
An introduction to OAuth 2
Best Practices in Building an API Security Ecosystem
Demystifying OAuth 2.0
Introduction to OAuth2.0
Securing RESTful API
OAuth2 - Introduction
OAuth2 & OpenID Connect
OAuth2 primer

What's hot (20)

PDF
Stateless Auth using OAuth2 & JWT
PPTX
Single-Page-Application & REST security
PDF
OAuth 2.0
PPTX
Securing your APIs with OAuth, OpenID, and OpenID Connect
PPTX
Securing RESTful APIs using OAuth 2 and OpenID Connect
PPTX
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
PPTX
OAuth2 + API Security
PPTX
OAuth 2
PPTX
Oauth 2.0 security
PPTX
API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...
PDF
Implementing OAuth
PPTX
Oauth2 and OWSM OAuth2 support
PDF
Security for oauth 2.0 - @topavankumarj
PDF
OAuth - Open API Authentication
PPTX
The State of OAuth2
PDF
A Survey on SSO Authentication protocols: Security and Performance
PPTX
An Introduction to OAuth2
PPTX
An Introduction to OAuth 2
PPTX
REST Service Authetication with TLS & JWTs
PDF
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Stateless Auth using OAuth2 & JWT
Single-Page-Application & REST security
OAuth 2.0
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
OAuth2 + API Security
OAuth 2
Oauth 2.0 security
API Security & Federation Patterns - Francois Lascelles, Chief Architect, Lay...
Implementing OAuth
Oauth2 and OWSM OAuth2 support
Security for oauth 2.0 - @topavankumarj
OAuth - Open API Authentication
The State of OAuth2
A Survey on SSO Authentication protocols: Security and Performance
An Introduction to OAuth2
An Introduction to OAuth 2
REST Service Authetication with TLS & JWTs
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
Ad

Viewers also liked (6)

PDF
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
PPTX
Open api개발을 위한 자료1
PDF
Daum OAuth 2.0
PDF
기획자를 위한 OAuth
PDF
OAuth2 - API 인증을 위한 만능도구상자
PDF
OAuth2.0
안드로이드 OAuth 1.0a, 2.0 구현 - Naver, Google API
Open api개발을 위한 자료1
Daum OAuth 2.0
기획자를 위한 OAuth
OAuth2 - API 인증을 위한 만능도구상자
OAuth2.0
Ad

Similar to O auth2.0 guide (20)

PDF
Stateless Auth using OAUTH2 & JWT
PPTX
OAuth2 Implementation Presentation (Java)
PDF
Api security with OAuth
PPTX
Devteach 2017 OAuth and Open id connect demystified
PDF
Keeping Pace with OAuth’s Evolving Security Practices.pdf
PDF
ConFoo 2015 - Securing RESTful resources with OAuth2
PDF
OAuth Base Camp
PDF
Spring4 security oauth2
PDF
Spring4 security oauth2
PPTX
PDF
Oauth2.0 tutorial
PDF
RFC6749 et alia 20130504
PDF
CIS13: Introduction to OAuth 2.0
PDF
OAuth2
PPTX
Id fiware upm-dit
PDF
Spring security oauth2
PDF
Full stack security
PDF
Lecture #25 : Oauth 2.0
PDF
How to authenticate users in your apps using FI-WARE Account - Introduction
PDF
OAuth: Trust Issues
Stateless Auth using OAUTH2 & JWT
OAuth2 Implementation Presentation (Java)
Api security with OAuth
Devteach 2017 OAuth and Open id connect demystified
Keeping Pace with OAuth’s Evolving Security Practices.pdf
ConFoo 2015 - Securing RESTful resources with OAuth2
OAuth Base Camp
Spring4 security oauth2
Spring4 security oauth2
Oauth2.0 tutorial
RFC6749 et alia 20130504
CIS13: Introduction to OAuth 2.0
OAuth2
Id fiware upm-dit
Spring security oauth2
Full stack security
Lecture #25 : Oauth 2.0
How to authenticate users in your apps using FI-WARE Account - Introduction
OAuth: Trust Issues

Recently uploaded (20)

PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
1. Introduction to Computer Programming.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Tartificialntelligence_presentation.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
project resource management chapter-09.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
DP Operators-handbook-extract for the Mautical Institute
Heart disease approach using modified random forest and particle swarm optimi...
1 - Historical Antecedents, Social Consideration.pdf
Unlocking AI with Model Context Protocol (MCP)
1. Introduction to Computer Programming.pptx
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Web App vs Mobile App What Should You Build First.pdf
Tartificialntelligence_presentation.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
Assigned Numbers - 2025 - Bluetooth® Document
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25-Week II
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Chapter 5: Probability Theory and Statistics
Programs and apps: productivity, graphics, security and other tools
project resource management chapter-09.pdf
Building Integrated photovoltaic BIPV_UPV.pdf

O auth2.0 guide

  • 1. 1 * E-mails: sales@nexright.com
  • 3. Why using OAuth2.0 ? one way to address REST security issues is with the open source protocol OAuth 1) Lack of standards and support of RESTfulAPI Askingauserfortheirpasswordhasanumberofside-effectsuchas: Trust:ausermaynottrustprovidingtheirpasswordtoyourapplication. Expandedaccessandrisks:Whentheuserprovidestheirpasswordtoyourapplication,yougetaccesstonotonlythedatayourapplicationneeds,butallotherdataintheuser’saccount.Theapplicationhasanobligationtoitsuserstosecurelystorethesepasswordsandpreventthemfromleaking.Manydevelopersdonotwanttheriskexposureofhavingthisadditionalresponsibility. Decreasedusersensitivitytophishing:Eveniftheuseriscomfortableprovidingtheirpasswordtoyourapplication,makingtheusercomfortabledoingthisaroundtheWebcanhavenegativelong-termeffects,suchasmakingphishingscamsmoreeffective. Limitedreliability:Whenauserchangestheirpassword,yourapplicationnolongerhasaccesstotheirdata. Revocationchallenges:Theonlywayausercanrevokeaccesstoyourapplicationisbychangingtheirpassword,whichalsorevokesaccesstoallotherapps. Passwordsbecomerequired:WhenanAPIprovidersupportsfederatedauthenticationmechanismssuchasOpenIDorSAML,usersmaynothavepasswordsontheiraccounts.ThismakesitimpossibleforthoseuserstouseapplicationspoweredbytheAPI. Difficultyimplementingstrongerauthentication:IfanAPIproviderrequirespasswordsforAPIauthentication,itbecomeschallengingtoimproveaccountsecuritywithtechnologieslikeCAPTCHAsormultifactorauthentication(suchasone-timepasswordtokens). 2)PasswordAnti-Pattern Within move towards SaaS–trend towards API access to data/services to supplement/replace browser access. Clear trend for these APIs is towards REST. 3) Cloud APIs 4) Native Mobile Applications 3 Nasrin Sohrabi
  • 4. Client Application User Agent How does OAuth2.0 work? OAuth 2.0 protocol uses a number of actors to achieve the main tasks of getting, validating, and using an access token 4 Nasrin Sohrabi Authorization Server Resource Server Resource Owner
  • 5. The main Actors are: User or Resource Owner Theactualenduser,responsibleforauthenticationandtoprovideconsenttosharetheirresourceswiththerequestingclient User Agent Theuser’sbrowser.usedforredirect‐basedflowswheretheusermustauthenticateandoptionallyprovideconsenttosharetheirresources. Client Authorization Server (AS) Resource Server (RS) The Client Application that is requesting an access token on behalf of the end user. A server capable of issuing tokens, obtaining authorization, and authenticating resource owners. The target application or API that provides the requested resources. This actor will validate an access token to provide authorization for theaction. (The server hosting protected resources) 5 Nasrin Sohrabi
  • 6. Oauth2.0 provides four standard grant typesandan extension grant type that can beusedto customize the authentication and authorization process depending on the application requirements: Server Side Web Application Flow (Authorization Code Flow) Client Side Web Application Flow (Implicit Grant Flow) Resource Owner Password Flow Client Credentials Extension Grant 6 Nasrin Sohrabi OAuth2.0 Grant Types
  • 7. Authorization Code Resource Owner Cridential Implicit Client Credentials Used for most Web and mobile application scenarios that want to call REST Web services. uses the user agent to transport an intermediate code, which is then exchanged for the OAuth2 tokens. Scenariowhereclientisnotabletosafelyhidetheclientsecret(e.g. clientsideJavaScriptapplication).UsestheuseragenttotransportTheOAuth2tokens. Whenapplicationneedstocontroltheloginform(e.g.NativeMobileapp). Exchangesausername/passwordcombinationfortheOAuth2tokens. Whenauserisnotinvolved.AccesstokenonlyrequiredforaservicetocallaRESTwebservice.ExchangestheclientcredentialsforanOAuth2Accesstoken. Extension Grant Type Used To Extend The Oauth2.0 Grant Types For specific Scenarios (e.g. the SAML bearer extension grant). 7 Nasrin Sohrabi
  • 8. Some of the important terminologies that use during work with OAuth: Client key: Client Secret: Authorization Code: Access Token: Refresh Token: AvalueusedbytheconsumertoidentifyitselftotheServiceProvider. A secret used by the consumer to establish ownership of the consumer key. Avalueusedbytheconsumertoobtainauthorizationfromtheuser,andexchangedforanAccessToken Atokenusedbytheclienttomakeauthenticatedrequestsonbehalfoftheresourceowner. Atokenusedbytheclienttoobtainanewaccesstokenwithouthavingtoinvolvetheresourceowner. 8 Nasrin Sohrabi
  • 9. 9 AS Enpoint Authorization Endpoints: • used, via user-agent redirection, to authenticate and obtain authorization from the resource owner. • End user on the front channel. Token Endpoints • Used to exchange an authorization grant for an access token. • Client on the back channel. Client Endpoint Redirection URI • After completing its interaction with the resource owner, the AS directs the resource owner's user-agent back to the client at the client’s redirection URI. • Front channel callback. Nasrin Sohrabi Endpoints
  • 10. The application developer will be responsible for the user-facing Elements Of theprocess. They will needto authenticate the user and interface with the back-end APIs. There are three main actions an application developer needs to handle to implement OAuth2: 1) Get an access token. 2) Use an access token. 3) Refresh an access token(optional). 10 Nasrin Sohrabi In the following slides, I will explained how to get an OAuth access token from PingFederate infrastructure, based on Authorization code grant type.
  • 12. Authorization code grant process Request Authorization Obtain User Authorization Exchange Code for Access Token Validate and Perform Actions There are 4 main steps to the authorization code grant type process: The client redirects the user to the Authorization Endpoint (Ping Federate)to request an authorization code. The Resource Owner (User) grants permissions for the client to access resource data. The authorization code is given to the client (callback from auth. server). The authorization code is exchanged for an access token given to the client by the Token Endpoint (Ping Federate) . The Resource Server validates the Access Token and gives access to the client if validation is successful 12 Nasrin Sohrabi
  • 13. Client Authorization EndPoint (PingFederate) Token EndPoint (PingFederate) Resource Server Grant Authorization Code Direct user To Resource Provider User Authentication Grant permissions Request Authorization Code Request Access Token Grant Access Token Direct users To the client with authcode 1 Obtain Authorization code 2 Obtain Authorization to use code Access Protected Resources Validate Token Use Access Token 3 Exchange Code for Access Token 4 Client Uses Resources 13 Nasrin Sohrabi
  • 14. Phases in detail: Theclientrequestsresourcedata,whichredirectstheuserthroughanauthorizationprocessinordertoobtainanauthorizationcode.AftertheuserauthenticatesandauthorizesaccessatPingFederate,acallback(viaanHTTP redirect)willbemadebacktotheclientapplicationwiththeauthorizationcodeinthequeryStringlike(https://localhost:9031/OAuthPlayground/case1callback.jsp?state=&code=5qJvl5hWL20KS6ZKzQ- eZAYBjF0coxe3YhPaAhM2).Now,theclientsitesendsanhttprequesttoexchangetheauthorizationcodeobtainedinthecallbackforthedesiredtokens(typicallyanaccesstokenandarefreshtoken).TheprocessofexchangingrequirestheclienttocommunicatewiththePingFederateTokenEndpoint(https://<pf>/as/token.oauth2)withthefollowingparameters:client_id,granttype=authorizationcodeandtheauthorizationcodereceivedinthepreviousstep.Forsecurityreasonsthecodecanonlybeusedonce.TheresultisanHTTP200responsetotheclientindicatingsuccessfromtheTokenendpoint.TheresponseisreturnedformattedinJSON(JavaScriptObjectotation) containingtheOAuthAccessToken.Theclientcannowusetheaccesstokentoperformactionsusingthedataitrequiresontheresourceserverbeforethetokenisexpired.TheresourceserverreceivestheaccesstokenandperformsavalidationcheckwiththeTokenendpointtomakesurethetokenisvalidbeforeperformingtherequiredaction. 14 Nasrin Sohrabi
  • 15. Authorization Endpoint Web Client (Our application) Browser Token Endpoint 1 4 3 2 1 Request query string includes the OAuth client ID, response type and requested scopes and redirect uri. Request Redirect to Authorization Server 3 5 15 Nasrin Sohrabi PingFederate Server
  • 16. WebapplicationredirectsusertoAuthorizationServer(AS),whichisPingFederate,atitsauthorizationendpoint(https://<pf>/as/authorization.oauth2).RequestquerystringincludestheOAuthclientID,responsetype(inthiscaseauthorizationcode)andrequestedscopesandstate. UserauthenticatestoASviaIdPadapterorIdPconnection.Afterauthentication,userseesconfirmationpagewithrequestedscopesfromtheOAuthclientredirect,andclicks"Approve” ASredirectsuserbacktoclientsitewithAuthorizationCodeinquerystring. WebsiteresolvesAuthorizationCodetoanOAuthtoken(AccessToken[andRefreshToken])viaAPIcalltotheASTokenEndpoint(https://<pf>/as/token.oauth2) TheresultisanHTTP200responsetotheclientindicatingsuccessfromtheTokenEndpoint.TheresponseisreturnedformattedinJSON(JavaScriptObjectNotation) containingtheOAuthAccessToken 2 4 5 1 3 16 Nasrin Sohrabi
  • 17. An example of authorization request from user and retrieve authorization code https://localhost:9031/as/authorization.oauth2? client_id=ac_client& response_type=code& scope=edit& redirect_uri=sample%3A%2F%2Foauth2%2Fcode%2Fcb 17 Nasrin Sohrabi
  • 18. 18 References: 1. Ryan Boyd, Getting Started with OAuth2.0, published by O’REILLY, February 2012. 2. OAuth2 Developers Guide, PingIdentity, 07/09/2014. 3. PingFederate Administrator’s Manual, June 27, 2014 . 4. Ryan Boyd, OAuth2 Identity and Data Access, 2012. 5. John DaSilva, Ping Identity and OAuth and OpenIDConnect In Action with PingFederate Hands-On, 7/8/2013. 6. OAuth2 Tutorial, Ping Identity, July 2014. Nasrin Sohrabi