SlideShare a Scribd company logo
1
Spring Security: OAuth2Spring Security: OAuth2
1
Sang ShinSang Shin
““Code with Passion!”Code with Passion!”
2
Topics
• What is OAuth2?
• Why OAuth2?
• Authorization code flow
3
What is OAuth2?What is OAuth2?
4
What is OAuth2?
• A protocol for conveying authorization decisions (via access token)
> It is NOT an authentication protocol
• Standard means of obtaining a token – there are four grant types
> Authorization code
> Resource owner password grant
> Implicit
> Client credentials
• Separation of client application from resource owner
> I, resource owner, authorize this app (client app) to perform these
actions on my behalf
5
What is OAuth2 Not?
• It is NOT an authentication protocol
> The user must be authenticated to obtain a token
> How the user is authenticated is outside of the spec
> How the token is validated is outside of the spec
> What the token contains is outside of the spec
6
Why OAuth2?Why OAuth2?
7
Securing Monolithic App
• You only need to authenticate the request once per user
• If there has been no session
> Verify user credentials
> Start a user session
> Provide role-based access control
• Else (session is already created)
> Verify session has not expired
• Method calls are trusted
8
Securing Monolithic App
• Pros
> Limited attack space
• Cons
> Once granted permission, the user has all the credentials for the rest of
the application including database access – once it is hacked, the whole
application is in danger
9
OAuth2 Secures Micro Services
• Single sign on (SSO)
• Stateless – backend services do not want to maintain user sessions
• Delegated access (access some resource on behalf of me)
• User credentials not exposed
• Fine grained authorization
• Interoperability with non browser clients
10
Authorization CodeAuthorization Code
FlowFlow
11
Authorization Code Flow - Actors
• Actors
> Resource owner (user)
> Client web app
> Resource server
> Auth. server
• Use case
> Microservices architecture –
client web app access
resources server on behalf of
user
> Consumer space – photo-
sharing app (client) want to
access user's friends data from
Facebook (resource server)
client
web app
auth server
resource
server
12
Authorization Code Flow – step 1
• User (Resource owner)
accesses the client web app
and does not have a session
with it
client
web app
auth server
resource
server
13
Authorization Code Flow – step 2
• Client redirects to its own
./login, which in turn, redirects
the request to the
“./oauth/authorize” endpoint of
the auth-server
• Note – the client web app has
to be configured with endpoint
location of the
“./oauth/authorize” of the auth
server via “user-authorization-
uri” property in its
application.yml
client
web app
auth server
resource
server
14
Authorization Code Flow – step 3
• Auth server redirects the user to
its login page since the user
isn't logged in to the auth server
• User logs in and is redirected
back to the “./oauth/authorize”
endpoint
client
web app
auth server
resource
server
15
Authorization Code Flow – step 4
• Use is then presented with “do
you approve for the client app
to perform some actions
specified in the scope?”
• User authorizes (or approve)
them
client
web app
auth server
resource
server
16
Authorization Code Flow – step 5
• Auth server redirects the user
back to the client web app with
one time code (in the query
params of the redirect)
client
web app
auth server
resource
server
17
Authorization Code Flow – step 6
• Client web app accesses
“./oauth/token” endpoint of the
auth server with the one-time
code
• Note – the client web app has
to be configured with endpoint
location of the “./oauth/token” of
the auth server via “access-
token-uri” property in its
application.yml
client
web app
auth server
resource
server
18
Authorization Code Flow – step 7
• Auth server responds with
access token
• Client web app starts an
authenticated session with the
auth server and saves the
access token in session
client
web app
auth server
resource
server
19
Authorization Code Flow – step 8
• Client web app accesses the
resource server with access
token
client
web app
auth server
resource
server
20
Authorization Code Flow – step 9
• Resource server verifies the
token with the auth-server
• Note – resource server has to
be configured with “user-info-
uri” in its application.yml
• Auth server sends back user
info back after verification
client
web app
auth server
resource
server
21
Authorization Code Flow – step 10
• Resource server responds back
with protected resource
• Client web app presents the
resource to the user
client
web app
auth server
resource
server
22
Code with Passion!Code with Passion!
22

More Related Content

PDF
Spring4 security oauth2
PDF
Spring security oauth2
PPTX
OAuth2 + API Security
PDF
ConFoo 2015 - Securing RESTful resources with OAuth2
PPTX
Best Practices in Building an API Security Ecosystem
PPTX
An introduction to OAuth 2
PPT
OAuth2 Protocol with Grails Spring Security
PDF
OAuth2 primer
Spring4 security oauth2
Spring security oauth2
OAuth2 + API Security
ConFoo 2015 - Securing RESTful resources with OAuth2
Best Practices in Building an API Security Ecosystem
An introduction to OAuth 2
OAuth2 Protocol with Grails Spring Security
OAuth2 primer

What's hot (20)

PDF
Learn with WSO2 - API Security
PPTX
Single-Page-Application & REST security
PDF
Introduction to OAuth2.0
PDF
Stateless Auth using OAuth2 & JWT
ODP
OAuth2 - Introduction
PPTX
Extended Security with WSO2 API Management Platform
PPTX
OAuth
PPTX
An Introduction to OAuth 2
PDF
The Ultimate Guide to Mobile API Security
PPTX
OAuth in the new .NET world (OWIN)
PPTX
An Introduction to OAuth2
PPTX
Securing your APIs with OAuth, OpenID, and OpenID Connect
PPTX
Web API 2 Token Based Authentication
PPTX
The State of OAuth2
PDF
Access Management for Cloud and Mobile
PDF
OAuth2 and Spring Security
PDF
Security for oauth 2.0 - @topavankumarj
PPTX
Securing RESTful APIs using OAuth 2 and OpenID Connect
PPTX
Microservice with OAuth2
PDF
OAuth - Open API Authentication
Learn with WSO2 - API Security
Single-Page-Application & REST security
Introduction to OAuth2.0
Stateless Auth using OAuth2 & JWT
OAuth2 - Introduction
Extended Security with WSO2 API Management Platform
OAuth
An Introduction to OAuth 2
The Ultimate Guide to Mobile API Security
OAuth in the new .NET world (OWIN)
An Introduction to OAuth2
Securing your APIs with OAuth, OpenID, and OpenID Connect
Web API 2 Token Based Authentication
The State of OAuth2
Access Management for Cloud and Mobile
OAuth2 and Spring Security
Security for oauth 2.0 - @topavankumarj
Securing RESTful APIs using OAuth 2 and OpenID Connect
Microservice with OAuth2
OAuth - Open API Authentication
Ad

Similar to Spring4 security oauth2 (20)

PDF
Stateless Auth using OAUTH2 & JWT
PPTX
OAuth2 Implementation Presentation (Java)
PPTX
OAuth 2
PPTX
Devteach 2017 OAuth and Open id connect demystified
PDF
OAuth: Trust Issues
PPTX
(1) OAuth 2.0 Overview
PPTX
Oauth2 and OWSM OAuth2 support
PPTX
OAuth 2 Spring Boot 3 Integration Presentation
PPTX
PPTX
Introduction to OAuth2
PDF
Stateless authentication for microservices applications - JavaLand 2015
PPTX
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
PDF
OAuth2
PDF
Top X OAuth 2 Hacks
PPT
Oauth2.0
PDF
Demystifying OAuth 2.0
PDF
Stateless authentication for microservices
PDF
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
PDF
OAuth 2.0
PDF
O auth2.0 guide
Stateless Auth using OAUTH2 & JWT
OAuth2 Implementation Presentation (Java)
OAuth 2
Devteach 2017 OAuth and Open id connect demystified
OAuth: Trust Issues
(1) OAuth 2.0 Overview
Oauth2 and OWSM OAuth2 support
OAuth 2 Spring Boot 3 Integration Presentation
Introduction to OAuth2
Stateless authentication for microservices applications - JavaLand 2015
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
OAuth2
Top X OAuth 2 Hacks
Oauth2.0
Demystifying OAuth 2.0
Stateless authentication for microservices
Stateless authentication with OAuth 2 and JWT - JavaZone 2015
OAuth 2.0
O auth2.0 guide
Ad

Recently uploaded (20)

PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Transform Your Business with a Software ERP System
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
top salesforce developer skills in 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Introduction to Artificial Intelligence
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administration Chapter 2
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Which alternative to Crystal Reports is best for small or large businesses.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Transform Your Business with a Software ERP System
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
CHAPTER 2 - PM Management and IT Context
wealthsignaloriginal-com-DS-text-... (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Digital Systems & Binary Numbers (comprehensive )
top salesforce developer skills in 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Introduction to Artificial Intelligence
Design an Analysis of Algorithms II-SECS-1021-03
Why Generative AI is the Future of Content, Code & Creativity?
medical staffing services at VALiNTRY
System and Network Administration Chapter 2

Spring4 security oauth2

  • 1. 1 Spring Security: OAuth2Spring Security: OAuth2 1 Sang ShinSang Shin ““Code with Passion!”Code with Passion!”
  • 2. 2 Topics • What is OAuth2? • Why OAuth2? • Authorization code flow
  • 4. 4 What is OAuth2? • A protocol for conveying authorization decisions (via access token) > It is NOT an authentication protocol • Standard means of obtaining a token – there are four grant types > Authorization code > Resource owner password grant > Implicit > Client credentials • Separation of client application from resource owner > I, resource owner, authorize this app (client app) to perform these actions on my behalf
  • 5. 5 What is OAuth2 Not? • It is NOT an authentication protocol > The user must be authenticated to obtain a token > How the user is authenticated is outside of the spec > How the token is validated is outside of the spec > What the token contains is outside of the spec
  • 7. 7 Securing Monolithic App • You only need to authenticate the request once per user • If there has been no session > Verify user credentials > Start a user session > Provide role-based access control • Else (session is already created) > Verify session has not expired • Method calls are trusted
  • 8. 8 Securing Monolithic App • Pros > Limited attack space • Cons > Once granted permission, the user has all the credentials for the rest of the application including database access – once it is hacked, the whole application is in danger
  • 9. 9 OAuth2 Secures Micro Services • Single sign on (SSO) • Stateless – backend services do not want to maintain user sessions • Delegated access (access some resource on behalf of me) • User credentials not exposed • Fine grained authorization • Interoperability with non browser clients
  • 11. 11 Authorization Code Flow - Actors • Actors > Resource owner (user) > Client web app > Resource server > Auth. server • Use case > Microservices architecture – client web app access resources server on behalf of user > Consumer space – photo- sharing app (client) want to access user's friends data from Facebook (resource server) client web app auth server resource server
  • 12. 12 Authorization Code Flow – step 1 • User (Resource owner) accesses the client web app and does not have a session with it client web app auth server resource server
  • 13. 13 Authorization Code Flow – step 2 • Client redirects to its own ./login, which in turn, redirects the request to the “./oauth/authorize” endpoint of the auth-server • Note – the client web app has to be configured with endpoint location of the “./oauth/authorize” of the auth server via “user-authorization- uri” property in its application.yml client web app auth server resource server
  • 14. 14 Authorization Code Flow – step 3 • Auth server redirects the user to its login page since the user isn't logged in to the auth server • User logs in and is redirected back to the “./oauth/authorize” endpoint client web app auth server resource server
  • 15. 15 Authorization Code Flow – step 4 • Use is then presented with “do you approve for the client app to perform some actions specified in the scope?” • User authorizes (or approve) them client web app auth server resource server
  • 16. 16 Authorization Code Flow – step 5 • Auth server redirects the user back to the client web app with one time code (in the query params of the redirect) client web app auth server resource server
  • 17. 17 Authorization Code Flow – step 6 • Client web app accesses “./oauth/token” endpoint of the auth server with the one-time code • Note – the client web app has to be configured with endpoint location of the “./oauth/token” of the auth server via “access- token-uri” property in its application.yml client web app auth server resource server
  • 18. 18 Authorization Code Flow – step 7 • Auth server responds with access token • Client web app starts an authenticated session with the auth server and saves the access token in session client web app auth server resource server
  • 19. 19 Authorization Code Flow – step 8 • Client web app accesses the resource server with access token client web app auth server resource server
  • 20. 20 Authorization Code Flow – step 9 • Resource server verifies the token with the auth-server • Note – resource server has to be configured with “user-info- uri” in its application.yml • Auth server sends back user info back after verification client web app auth server resource server
  • 21. 21 Authorization Code Flow – step 10 • Resource server responds back with protected resource • Client web app presents the resource to the user client web app auth server resource server
  • 22. 22 Code with Passion!Code with Passion! 22