SlideShare a Scribd company logo
1 of 61
Microservice Security with
Spring Security 5.1 , OAuth
2.0 and OpenID Connect
Monolith Security
Definition
OAuth 2.0 Authorization Framework :
Is a framework for allowing users to authorize applications to access their data on
there behalf.
Authorized applications get an access token that they can use to call a service.
Does not tell the authorized application anything about the identity of the user
Does not specify a token format. Expects other frameworks to extend it.
Life without OAuth
Life without OAuth
Life without OAuth
Life without OAuth
Life without OAuth
Life without OAuth
Life with OAuth
Life with OAuth
Life with OAuth
Life with OAuth
Life with OAuth
Step1 : Get Authorization Grant -
Authorization code grant
Protocol flow
Token flow
Token flow
Token flow
Token flow
Step 2 – Exchange for Access Token
Step 2 – Exchange for Access Token
Step 3 - Access Protected Resource
Step 3 - Access Protected Resource
The Complete Flow
With Refresh Token
With Refresh Token
Client Credentials
Application Registration
To participate in OAuth, your application has to first register with the service
provider (Google , Facebook, and so on) against which you plan to authenticate
by providing the application name, application URL, and callback URL.
The callback URI is where the service will redirect the user after they authorize
(or deny) your application, and therefore the part of your application that will
handle authorization codes or access tokens.
Successful registration of your application with the service provider gives you two
values unique to your application: client application_id and client_secret. client_id
can be exposed publicly but client_secret is kept hidden (private). Both these
values are needed whenever you access the service provider.
Client ID and Client Secret
Successful registration of your application with the service provider gives you two
values unique to your application: client application_id and client_secret.
client_id can be exposed publicly but client_secret is kept hidden (private). Both
these values are needed whenever you access the service provider.
The following diagram shows the interactions between these roles:
The steps in the preceding diagram detailed here:
1. The client application requests the resource owner to give them authorization to
access the secured resources
2. If the resource owner authorizes this, the authorization grant is sent to the client
application
3. The client application asks for a token, using the grant provided by the resource
owner along with authentication credentials from the authorization server
4. If the credentials and grant from the client application are valid, the
authorization server issues an Access Token to the client application.
5. The client application accesses the protected resources on the resource server
using the Access Token provided 6. If the Access Token sent by the client
application is valid, the resource server gives access to the secured resources
Authorization Grant Types
A grant type defines how a client can obtain an authorization grant from a
resource owner to access a resource on their behalf.In the Abstract Protocol Flow
above, the first four steps cover obtaining an authorization grant and access
token. The authorization grant type depends on the method used by the
application to request authorization, and the grant types supported by the API.
OAuth 2 defines four grant types, each of which is useful in different cases:
Authorization Grant Types
● Authorization Code: used with server-side Applications
● Implicit: used with Mobile Apps or Web Applications (applications that run on
the user's device)
● Resource Owner Password Credentials: used with trusted Applications,
such as those owned by the service itself
● Client Credentials: used with Applications API access
Authorization code flow
This a is very commonly used grant type and works on redirection at the server. It
is highly suitable for server-side applications where the source code is hosted on
the server and nothing is available on the client. The following diagram explains
the authorization code grant type flow:
Grant Type: Authorization Code
The authorization code grant type is the most commonly used because it is
optimized for server-side applications, where source code is not publicly exposed,
and Client Secret confidentiality can be maintained. This is a redirection-based
flow, which means that the application must be capable of interacting with the
user-agent (i.e. the user's web browser) and receiving API authorization codes
that are routed through the user-agent.
Grant Type: Authorization Code
1. The resource owner of the secured resource is presented with a screen in the
browser to authorize the request. Here is a sample authorization link:
https://<DOMAIN>/oauth/authorize?response_type=code&client_id=<CLIENT_ID>
&redirect_uri=<CALLBACK_URL>&scope=<SCOPE>
Grant Type: Authorization Code
These are the important query parameters in the previous link:
client_id: The client application ID that we got while registering the application
with the service provider.
redirect_uri: After successful authorization, the server redirects to this URL
supplied.
response_type: A very important parameter the client uses to ask the server for
the authorization code
scope: Specifies the level of access that it requires
Grant Type: Authorization Code
2. If the resource owner (user) allows this, they click on the authorize link, which is
sent to the authorization server.
3. If the authorization request sent to the authorization server is validated and
found to be successful, the client receives the authorization code grant from the
authorization server appended as a query parameter in the callback URL
(<CALLBACK_URL>?code=<AUTHORIZATION_CODE>) specified in Step 1.
4. Using the authorization grant, the client application requests an Access Token
from the authorization server
https://<DOMAIN>/oauth/token?client_id=<CLIENT_ID>&client_secret=<CLIENT_
SECRET>&grant_type=authorization_code&code=<AUTHORIZATION_CODE>&r
edirect_uri=CALLBACK_URL).
Grant Type: Authorization Code
In this URL, the client application's client_secret also has to be passed, along
with the grant_type parameter, which states that the code passed is the
authorization code.
5. The authorization server validates the credentials and authorization grant and
sends the Access Token to the client application, preferably in the form of JSON.
6. The client application calls the protected resource on the resource server using
the Access Token received in Step 5. 7. If the Access Token supplied in Step 5 is
valid, the resource server gives access to the secured resource.
Grant Type - Client Credentials
The client application sends credentials (the client's service account), along with
client_ID and client_secret, to the authorization server. If the supplied values are
valid, the authorization server sends the Access Token, which can be used to get
access to the secured resources.
Grant Type - Client Credentials
Request Parameters
grant_type (required)
The grant_type parameter must be set to client_credentials.
scope (optional)
Your service can support different scopes for the client credentials grant. In
practice, not many services actually support this.
Client Authentication (required)
The client needs to authenticate themselves for this request. Typically the service
will allow either additional request parameters client_id and client_secret, or
accept the client ID and secret in the HTTP Basic auth header.
Access Token and Refresh Token
The Access Token can be used by the client application to retrieve information
from the resource server for a stipulated time for which the token is deemed valid.
After this, the server will reject the request with the appropriate HTTP response
error code. Along with the Access Token, OAuth allows the authorization server to
also send another token, the Refresh Token. When the Access Token expires, the
client application can use this second token to request the authorization server to
provide a new Access Token.
JSON Web Token (JWT)
"JSON Web Tokens are an open, industry standard RFC 7519 method for
representing claims securely between two parties."
Each request sends the cookie (session ID) in the form of an HTTP header, which
gets validated by the server, and a state (a user session) is associated with each
request. In modern applications a server-side session ID is replaced with the JWT.
The following diagram shows the workings of the JWT:
Client Credentials Flow
JWT
JWT
The web server, in this case, doesn't create a user session and the user session
management capability needed for a stateful application is offloaded to other
mechanisms. In the world of the Spring Framework, the Spring Session module
can be employed to externalize the session from the web server to a central
persistence store (Redis, Couchbase, and so on). Every request containing a valid
token (JWT) is validated against this external store of authenticity and validity.
After successful authentication, applications can generate a valid token and send
it as a response to the client. The client can then store this token in any client
storage mechanism it uses (sessionStorage, localStorage, cookies, and so on, in
a browser). Using Spring Security, we can validate this token to ascertain the
authenticity and validity of the user and then do whatever is required
Structure of a token
The structure of the JWT consists of a header, payload, and a signature. As
mentioned, rather than encryption, the data contained within the JWT is encoded
and then signed. Encoding does the job of transforming the data in a way that is
acceptable by a variety of parties and signing allows us to check for its authenticity
and, in fact, its origin:
Header This is a JSON object and takes the following format. It gives information
on how the signature should be computed.
{
"alg": "HS256",
"typ": "JWT"
}
PayLoad
The payload forms the actual data (also known as a claim) stored in the JWT.
According to your application's requirements, you can put any number of claims
into your JWT payload component. There are some predefined claims, such as iss
(issuer), sub (subject), exp (expiration time), iat (issued at), and so on, that can be
used, but all of these are optional:
{
"sub": "1234567890",
"username": "Test User",
"iat": 1516239022
}
OpenID Connect
OpenID Connect implements authentication as an extension to the
OAuth 2.0 authorization process. Use of this extension is requested
by Clients by including the openid scope value in the Authorization
Request. An Authorization Request using these extensions is called
an Authentication Request.
Information about the authentication performed is returned in a
JSON Web Token (JWT) [JWT] called an ID Token (see Section
2.2). OAuth 2.0 Authentication Servers implementing OpenID
Connect are also referred to as OpenID Providers (OPs). OAuth 2.0
Clients using OpenID Connect are also referred to as Relying
Parties (RPs).
OpenID Connect - Id Token
ID Token-
With OpenID Connect authentication, there is an additional type of
OAuth token: an ID token. The ID token, or id_token, represents
the identity of the user being authenticated. This is a separate
token from the access token, which is used to retrieve the user’s
profile information or other user data requested during the same
authorization flow.The ID token is a JSON Web Token (JWT), which
is a digitally signed and/or encrypted representation of the user’s
identity asserted by the identity provider. Instead of using
cryptographic operations to validate the JSON Web Token, it can
be treated as an opaque string and passed to the Check ID
Endpoint for interpretation (see below). This flexibility keeps with
OpenID Connect - Id Token
ID Token-
With OpenID Connect authentication, there is an additional type of
OAuth token: an ID token. The ID token, or id_token, represents
the identity of the user being authenticated. This is a separate
token from the access token, which is used to retrieve the user’s
profile information or other user data requested during the same
authorization flow.The ID token is a JSON Web Token (JWT), which
is a digitally signed and/or encrypted representation of the user’s
identity asserted by the identity provider.
Open ID connect layer
Thank you !

More Related Content

What's hot

Authentication through Claims-Based Authentication
Authentication through Claims-Based AuthenticationAuthentication through Claims-Based Authentication
Authentication through Claims-Based Authenticationijtsrd
 
Intro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectIntro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectLiamWadman
 
An introduction to OAuth 2
An introduction to OAuth 2An introduction to OAuth 2
An introduction to OAuth 2Sanjoy Kumar Roy
 
CIS14: Working with OAuth and OpenID Connect
CIS14: Working with OAuth and OpenID ConnectCIS14: Working with OAuth and OpenID Connect
CIS14: Working with OAuth and OpenID ConnectCloudIDSummit
 
1000 ways to die in mobile oauth
1000 ways to die in mobile oauth1000 ways to die in mobile oauth
1000 ways to die in mobile oauthPriyanka Aash
 
O auth2 with angular js
O auth2 with angular jsO auth2 with angular js
O auth2 with angular jsBixlabs
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectManish Pandit
 
Spring security oauth2
Spring security oauth2Spring security oauth2
Spring security oauth2axykim00
 
OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?Oliver Pfaff
 
CIS14: OAuth and OpenID Connect in Action
CIS14: OAuth and OpenID Connect in ActionCIS14: OAuth and OpenID Connect in Action
CIS14: OAuth and OpenID Connect in ActionCloudIDSummit
 
SAML VS OAuth 2.0 VS OpenID Connect
SAML VS OAuth 2.0 VS OpenID ConnectSAML VS OAuth 2.0 VS OpenID Connect
SAML VS OAuth 2.0 VS OpenID ConnectUbisecure
 
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356Survey on Restful Web Services Using Open Authorization (Oauth)I01545356
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356IOSR Journals
 

What's hot (20)

Authentication through Claims-Based Authentication
Authentication through Claims-Based AuthenticationAuthentication through Claims-Based Authentication
Authentication through Claims-Based Authentication
 
Introduction to OAuth2.0
Introduction to OAuth2.0Introduction to OAuth2.0
Introduction to OAuth2.0
 
OAuth2 primer
OAuth2 primerOAuth2 primer
OAuth2 primer
 
Intro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectIntro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID Connect
 
An introduction to OAuth 2
An introduction to OAuth 2An introduction to OAuth 2
An introduction to OAuth 2
 
CIS14: Working with OAuth and OpenID Connect
CIS14: Working with OAuth and OpenID ConnectCIS14: Working with OAuth and OpenID Connect
CIS14: Working with OAuth and OpenID Connect
 
1000 ways to die in mobile oauth
1000 ways to die in mobile oauth1000 ways to die in mobile oauth
1000 ways to die in mobile oauth
 
O auth2.0 guide
O auth2.0 guideO auth2.0 guide
O auth2.0 guide
 
OAuth2 Presentaion
OAuth2 PresentaionOAuth2 Presentaion
OAuth2 Presentaion
 
SAML 2
SAML 2SAML 2
SAML 2
 
O auth2 with angular js
O auth2 with angular jsO auth2 with angular js
O auth2 with angular js
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
Spring security oauth2
Spring security oauth2Spring security oauth2
Spring security oauth2
 
Web services security_in_wse_3_ppt
Web services security_in_wse_3_pptWeb services security_in_wse_3_ppt
Web services security_in_wse_3_ppt
 
OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?OpenID Connect - An Emperor or Just New Cloths?
OpenID Connect - An Emperor or Just New Cloths?
 
CIS14: OAuth and OpenID Connect in Action
CIS14: OAuth and OpenID Connect in ActionCIS14: OAuth and OpenID Connect in Action
CIS14: OAuth and OpenID Connect in Action
 
Restful api
Restful apiRestful api
Restful api
 
SAML VS OAuth 2.0 VS OpenID Connect
SAML VS OAuth 2.0 VS OpenID ConnectSAML VS OAuth 2.0 VS OpenID Connect
SAML VS OAuth 2.0 VS OpenID Connect
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0
 
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356Survey on Restful Web Services Using Open Authorization (Oauth)I01545356
Survey on Restful Web Services Using Open Authorization (Oauth)I01545356
 

Similar to Microservice security with spring security 5.1,Oauth 2.0 and open id connect

OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...Good Dog Labs, Inc.
 
Microsoft Graph API Delegated Permissions
Microsoft Graph API Delegated PermissionsMicrosoft Graph API Delegated Permissions
Microsoft Graph API Delegated PermissionsStefan Weber
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportGaurav Sharma
 
Stateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWTStateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWTMobiliya
 
Deep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected AppsDeep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected AppsSalesforce Developers
 
.NET Core, ASP.NET Core Course, Session 19
 .NET Core, ASP.NET Core Course, Session 19 .NET Core, ASP.NET Core Course, Session 19
.NET Core, ASP.NET Core Course, Session 19aminmesbahi
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTGaurav Roy
 
Amazon Cognito OAuth 2.0 Grants
Amazon Cognito OAuth 2.0 GrantsAmazon Cognito OAuth 2.0 Grants
Amazon Cognito OAuth 2.0 GrantsSibtay Abbas
 
Oauth 2.0 security
Oauth 2.0 securityOauth 2.0 security
Oauth 2.0 securityvinoth kumar
 
Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0Functional Imperative
 
(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overviewanikristo
 
OAuth2 and OpenID with Spring Boot
OAuth2 and OpenID with Spring BootOAuth2 and OpenID with Spring Boot
OAuth2 and OpenID with Spring BootGeert Pante
 
Protecting your APIs with OAuth 2.0
Protecting your APIs with OAuth 2.0Protecting your APIs with OAuth 2.0
Protecting your APIs with OAuth 2.0Ubisecure
 
e-SUAP - Security - Windows azure access control list (english version)
e-SUAP - Security - Windows azure access control list (english version)e-SUAP - Security - Windows azure access control list (english version)
e-SUAP - Security - Windows azure access control list (english version)Sabino Labarile
 
(4) OAuth 2.0 Obtaining Authorization
(4) OAuth 2.0 Obtaining Authorization(4) OAuth 2.0 Obtaining Authorization
(4) OAuth 2.0 Obtaining Authorizationanikristo
 

Similar to Microservice security with spring security 5.1,Oauth 2.0 and open id connect (20)

OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...OAuth 2.0  - The fundamentals, the good , the bad, technical primer and commo...
OAuth 2.0 - The fundamentals, the good , the bad, technical primer and commo...
 
Microsoft Graph API Delegated Permissions
Microsoft Graph API Delegated PermissionsMicrosoft Graph API Delegated Permissions
Microsoft Graph API Delegated Permissions
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
 
Lecture #25 : Oauth 2.0
Lecture #25 : Oauth 2.0Lecture #25 : Oauth 2.0
Lecture #25 : Oauth 2.0
 
Stateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWTStateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWT
 
Deep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected AppsDeep Dive into OAuth for Connected Apps
Deep Dive into OAuth for Connected Apps
 
OAuth2 + API Security
OAuth2 + API SecurityOAuth2 + API Security
OAuth2 + API Security
 
.NET Core, ASP.NET Core Course, Session 19
 .NET Core, ASP.NET Core Course, Session 19 .NET Core, ASP.NET Core Course, Session 19
.NET Core, ASP.NET Core Course, Session 19
 
OAuth 2
OAuth 2OAuth 2
OAuth 2
 
Introduction to OAuth2
Introduction to OAuth2Introduction to OAuth2
Introduction to OAuth2
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWT
 
Amazon Cognito OAuth 2.0 Grants
Amazon Cognito OAuth 2.0 GrantsAmazon Cognito OAuth 2.0 Grants
Amazon Cognito OAuth 2.0 Grants
 
Oauth 2.0 security
Oauth 2.0 securityOauth 2.0 security
Oauth 2.0 security
 
API Security with OAuth2.0.
API Security with OAuth2.0.API Security with OAuth2.0.
API Security with OAuth2.0.
 
Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0Intro to API Security with Oauth 2.0
Intro to API Security with Oauth 2.0
 
(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview
 
OAuth2 and OpenID with Spring Boot
OAuth2 and OpenID with Spring BootOAuth2 and OpenID with Spring Boot
OAuth2 and OpenID with Spring Boot
 
Protecting your APIs with OAuth 2.0
Protecting your APIs with OAuth 2.0Protecting your APIs with OAuth 2.0
Protecting your APIs with OAuth 2.0
 
e-SUAP - Security - Windows azure access control list (english version)
e-SUAP - Security - Windows azure access control list (english version)e-SUAP - Security - Windows azure access control list (english version)
e-SUAP - Security - Windows azure access control list (english version)
 
(4) OAuth 2.0 Obtaining Authorization
(4) OAuth 2.0 Obtaining Authorization(4) OAuth 2.0 Obtaining Authorization
(4) OAuth 2.0 Obtaining Authorization
 

Recently uploaded

Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 

Recently uploaded (20)

Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 

Microservice security with spring security 5.1,Oauth 2.0 and open id connect

  • 1. Microservice Security with Spring Security 5.1 , OAuth 2.0 and OpenID Connect
  • 3.
  • 4.
  • 5.
  • 6. Definition OAuth 2.0 Authorization Framework : Is a framework for allowing users to authorize applications to access their data on there behalf. Authorized applications get an access token that they can use to call a service. Does not tell the authorized application anything about the identity of the user Does not specify a token format. Expects other frameworks to extend it.
  • 7.
  • 8.
  • 20.
  • 21. Step1 : Get Authorization Grant - Authorization code grant
  • 22.
  • 28. Step 2 – Exchange for Access Token
  • 29. Step 2 – Exchange for Access Token
  • 30. Step 3 - Access Protected Resource
  • 31. Step 3 - Access Protected Resource
  • 36.
  • 37. Application Registration To participate in OAuth, your application has to first register with the service provider (Google , Facebook, and so on) against which you plan to authenticate by providing the application name, application URL, and callback URL. The callback URI is where the service will redirect the user after they authorize (or deny) your application, and therefore the part of your application that will handle authorization codes or access tokens. Successful registration of your application with the service provider gives you two values unique to your application: client application_id and client_secret. client_id can be exposed publicly but client_secret is kept hidden (private). Both these values are needed whenever you access the service provider.
  • 38. Client ID and Client Secret Successful registration of your application with the service provider gives you two values unique to your application: client application_id and client_secret. client_id can be exposed publicly but client_secret is kept hidden (private). Both these values are needed whenever you access the service provider. The following diagram shows the interactions between these roles:
  • 39. The steps in the preceding diagram detailed here: 1. The client application requests the resource owner to give them authorization to access the secured resources 2. If the resource owner authorizes this, the authorization grant is sent to the client application 3. The client application asks for a token, using the grant provided by the resource owner along with authentication credentials from the authorization server 4. If the credentials and grant from the client application are valid, the authorization server issues an Access Token to the client application. 5. The client application accesses the protected resources on the resource server using the Access Token provided 6. If the Access Token sent by the client application is valid, the resource server gives access to the secured resources
  • 40. Authorization Grant Types A grant type defines how a client can obtain an authorization grant from a resource owner to access a resource on their behalf.In the Abstract Protocol Flow above, the first four steps cover obtaining an authorization grant and access token. The authorization grant type depends on the method used by the application to request authorization, and the grant types supported by the API. OAuth 2 defines four grant types, each of which is useful in different cases:
  • 41. Authorization Grant Types ● Authorization Code: used with server-side Applications ● Implicit: used with Mobile Apps or Web Applications (applications that run on the user's device) ● Resource Owner Password Credentials: used with trusted Applications, such as those owned by the service itself ● Client Credentials: used with Applications API access
  • 42. Authorization code flow This a is very commonly used grant type and works on redirection at the server. It is highly suitable for server-side applications where the source code is hosted on the server and nothing is available on the client. The following diagram explains the authorization code grant type flow:
  • 43. Grant Type: Authorization Code The authorization code grant type is the most commonly used because it is optimized for server-side applications, where source code is not publicly exposed, and Client Secret confidentiality can be maintained. This is a redirection-based flow, which means that the application must be capable of interacting with the user-agent (i.e. the user's web browser) and receiving API authorization codes that are routed through the user-agent.
  • 44. Grant Type: Authorization Code 1. The resource owner of the secured resource is presented with a screen in the browser to authorize the request. Here is a sample authorization link: https://<DOMAIN>/oauth/authorize?response_type=code&client_id=<CLIENT_ID> &redirect_uri=<CALLBACK_URL>&scope=<SCOPE>
  • 45. Grant Type: Authorization Code These are the important query parameters in the previous link: client_id: The client application ID that we got while registering the application with the service provider. redirect_uri: After successful authorization, the server redirects to this URL supplied. response_type: A very important parameter the client uses to ask the server for the authorization code scope: Specifies the level of access that it requires
  • 46. Grant Type: Authorization Code 2. If the resource owner (user) allows this, they click on the authorize link, which is sent to the authorization server. 3. If the authorization request sent to the authorization server is validated and found to be successful, the client receives the authorization code grant from the authorization server appended as a query parameter in the callback URL (<CALLBACK_URL>?code=<AUTHORIZATION_CODE>) specified in Step 1. 4. Using the authorization grant, the client application requests an Access Token from the authorization server https://<DOMAIN>/oauth/token?client_id=<CLIENT_ID>&client_secret=<CLIENT_ SECRET>&grant_type=authorization_code&code=<AUTHORIZATION_CODE>&r edirect_uri=CALLBACK_URL).
  • 47. Grant Type: Authorization Code In this URL, the client application's client_secret also has to be passed, along with the grant_type parameter, which states that the code passed is the authorization code. 5. The authorization server validates the credentials and authorization grant and sends the Access Token to the client application, preferably in the form of JSON. 6. The client application calls the protected resource on the resource server using the Access Token received in Step 5. 7. If the Access Token supplied in Step 5 is valid, the resource server gives access to the secured resource.
  • 48. Grant Type - Client Credentials The client application sends credentials (the client's service account), along with client_ID and client_secret, to the authorization server. If the supplied values are valid, the authorization server sends the Access Token, which can be used to get access to the secured resources.
  • 49. Grant Type - Client Credentials Request Parameters grant_type (required) The grant_type parameter must be set to client_credentials. scope (optional) Your service can support different scopes for the client credentials grant. In practice, not many services actually support this. Client Authentication (required) The client needs to authenticate themselves for this request. Typically the service will allow either additional request parameters client_id and client_secret, or accept the client ID and secret in the HTTP Basic auth header.
  • 50. Access Token and Refresh Token The Access Token can be used by the client application to retrieve information from the resource server for a stipulated time for which the token is deemed valid. After this, the server will reject the request with the appropriate HTTP response error code. Along with the Access Token, OAuth allows the authorization server to also send another token, the Refresh Token. When the Access Token expires, the client application can use this second token to request the authorization server to provide a new Access Token.
  • 51. JSON Web Token (JWT) "JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties." Each request sends the cookie (session ID) in the form of an HTTP header, which gets validated by the server, and a state (a user session) is associated with each request. In modern applications a server-side session ID is replaced with the JWT. The following diagram shows the workings of the JWT:
  • 53. JWT
  • 54. JWT The web server, in this case, doesn't create a user session and the user session management capability needed for a stateful application is offloaded to other mechanisms. In the world of the Spring Framework, the Spring Session module can be employed to externalize the session from the web server to a central persistence store (Redis, Couchbase, and so on). Every request containing a valid token (JWT) is validated against this external store of authenticity and validity. After successful authentication, applications can generate a valid token and send it as a response to the client. The client can then store this token in any client storage mechanism it uses (sessionStorage, localStorage, cookies, and so on, in a browser). Using Spring Security, we can validate this token to ascertain the authenticity and validity of the user and then do whatever is required
  • 55. Structure of a token The structure of the JWT consists of a header, payload, and a signature. As mentioned, rather than encryption, the data contained within the JWT is encoded and then signed. Encoding does the job of transforming the data in a way that is acceptable by a variety of parties and signing allows us to check for its authenticity and, in fact, its origin: Header This is a JSON object and takes the following format. It gives information on how the signature should be computed. { "alg": "HS256", "typ": "JWT" }
  • 56. PayLoad The payload forms the actual data (also known as a claim) stored in the JWT. According to your application's requirements, you can put any number of claims into your JWT payload component. There are some predefined claims, such as iss (issuer), sub (subject), exp (expiration time), iat (issued at), and so on, that can be used, but all of these are optional: { "sub": "1234567890", "username": "Test User", "iat": 1516239022 }
  • 57. OpenID Connect OpenID Connect implements authentication as an extension to the OAuth 2.0 authorization process. Use of this extension is requested by Clients by including the openid scope value in the Authorization Request. An Authorization Request using these extensions is called an Authentication Request. Information about the authentication performed is returned in a JSON Web Token (JWT) [JWT] called an ID Token (see Section 2.2). OAuth 2.0 Authentication Servers implementing OpenID Connect are also referred to as OpenID Providers (OPs). OAuth 2.0 Clients using OpenID Connect are also referred to as Relying Parties (RPs).
  • 58. OpenID Connect - Id Token ID Token- With OpenID Connect authentication, there is an additional type of OAuth token: an ID token. The ID token, or id_token, represents the identity of the user being authenticated. This is a separate token from the access token, which is used to retrieve the user’s profile information or other user data requested during the same authorization flow.The ID token is a JSON Web Token (JWT), which is a digitally signed and/or encrypted representation of the user’s identity asserted by the identity provider. Instead of using cryptographic operations to validate the JSON Web Token, it can be treated as an opaque string and passed to the Check ID Endpoint for interpretation (see below). This flexibility keeps with
  • 59. OpenID Connect - Id Token ID Token- With OpenID Connect authentication, there is an additional type of OAuth token: an ID token. The ID token, or id_token, represents the identity of the user being authenticated. This is a separate token from the access token, which is used to retrieve the user’s profile information or other user data requested during the same authorization flow.The ID token is a JSON Web Token (JWT), which is a digitally signed and/or encrypted representation of the user’s identity asserted by the identity provider.