SlideShare a Scribd company logo
1 of 22
Download to read offline
Protecting web APIs with 
OAuth 2.0 
Vladimir Dzhuvinov
Bearer Token 
Your cool web API
HTTPS request with a bearer token 
GET /client-reg HTTP/1.1 
Host: c2id.com 
Authorization: Bearer ztucZS1ZyFKgh0tUEruUtiSTXhnexmd6 
type token value
Successful HTTP response 
HTTP/1.1 200 OK 
Content-Type: application/json 
Cache-Control: no-store 
Pragma: no-cache 
{ … }
On missing token 
HTTP/1.1 401 Unauthorized 
WWW-Authenticate: Bearer
On invalid / expired token 
HTTP/1.1 401 Unauthorized 
WWW-Authenticate: Bearer error=”invalid_token”
On token with insufficient 
privileges 
HTTP/1.1 403 Forbidden 
WWW-Authenticate: Bearer error=”insufficient_scope”
To learn more about 
bearer token usage 
See RFC 6750 
[ http://tools.ietf.org/html/rfc6750 ]
How does your web API 
decode the access tokens? 
Your W eb API
Typical authorisation attributes 
associated with an access token 
● Scope: e.g. read, 
write, admin... 
● Expiration time 
● User ID 
● Client ID 
● Issuer
The 2 possible token encodings 
● Self-contained: 
– Require RSA signature 
verification, < 1 ms 
– Scale extremely well 
● Identifier-based: 
– Require web API 
lookup, ~100+ ms 
– Don't scale well, avoid
JSON Web Tokens (JWT) 
eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm 
9maWxlIl0sImV4cCI6MTQxNDA2NTEzNCwic3ViIjoiYWxpY2UiLCJpc3MiOiJodHRw 
OlwvXC9sb2NhbGhvc3Q6ODA4MFwvYzJpZCIsImlhdCI6MTQxNDA2NDUzNCwiY2l 
kIjoiMDAwMTIzIn0.fBZW6U9r7M53fwhoEtC9Bxi8U1ytQvpy8pmHylvvvhEZimluNkw 
mDXWIoHuXIgX9ZfqMp9layftbFE7DVeo3wDpGNM9UtOo8Ccpv7rKrcN60ai6G2hop 
e7sCRvWTqYx2g8Mk7UOT061Feei7RMYFekO5pFPxSDiKyHCQjbkU 
Syntax: 
BASE64URL(header) + 
“.” + 
BASE64URL(JSON-claims) + 
“.” + 
BASE64URL(RSA-signature)
JSON Web Tokens (JWT) 
Header 
{ "alg": "RS256", "kid": "1" } 
Claims 
{ "sub": "alice", 
"cid": "000123", 
"iss": "https://connect2id.com", 
"exp": 1414065134, 
"iat": 1414064534, 
"scp": [ "read", "write", "admin" ] 
} 
Signature (RSA) 
fBZW6U9r7M53fwh­oEtC9 
Bxi8U1ytQvpy8pmHylvvvhEZimlu­NkwmDXWIoHuXIgX9ZfqMp9layftbFE7DVeo­3wDpGNM9UtOo8Cc
To learn more about JWT 
See draft-ietf-oauth-json-web-token-29 
[ http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-29 ]
The ultimate Java library for JWT 
http://connect2id.com/products/nimbus-jose-jwt 
Thousands of deployments, tens of reviewers and 
contributors 
Connect2id, Mitre Corp, Microsoft, EA, Square, Zendesk, 
CertiVox, Harvard Medical Schools, unnamed banks, etc.
Who issues the access tokens?
Your authorisation server 
Authenticates 
users and clients, 
issues tokens 
OAuth 2.0 
server 
mobile app 
web app 
native app 
Web API Web API Web API 
Web APIs service requests, need only understand access tokens
The OAuth 2.0 grants 
● Authorisation code – require browser for end-user 
interaction 
● Implicit – for browser (JS) based apps 
● Password – for native apps 
● Client credentials – for clients acting on their own 
behalf 
● Assertions: 
– SAML 2.0 Bearer 
– JWT Bearer
To learn more about OAuth 2.0 
See RFC 6749 
[ http://tools.ietf.org/html/rfc6749 ]
OpenID Connect 
● Identity layer on top of the OAuth 2.0 framework 
● The server issues an ID token in addition to the 
access token: 
– The ID token is a signed JWT with claims: 
● Subject – the end-user ID 
● Issuer – the authority 
● Issue and expiration date 
● Audience – the intended recipients 
● Authentication strength and methods
ID token claims 
{ 
"sub" : "alice", 
"iss" : "https://connect2id.com", 
"iat" : 1414076589, 
"exp" : 1414077489, 
"aud" : [ "000123" ], 
"ip_address" : "10.20.30.40", 
"acr" : "1", 
"amr" : [ "ldap" ] 
}
To learn more about 
OpenID Connect 
See 
OpenID Connect 1.0 Core 
OpenID Connect 1.0 Discovery 
OpenID Connect 1.0 Dynamic Registration 
OpenID Connect 1.0 Session Management 
[ http://openid.net/connect/ ]

More Related Content

What's hot

Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST security
Igor Bossenko
 

What's hot (20)

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
 
JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2JavaOne 2014 - Securing RESTful Resources with OAuth2
JavaOne 2014 - Securing RESTful Resources with OAuth2
 
Single-Page-Application & REST security
Single-Page-Application & REST securitySingle-Page-Application & REST security
Single-Page-Application & REST security
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
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?
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWT
 
Mit 2014 introduction to open id connect and o-auth 2
Mit 2014   introduction to open id connect and o-auth 2Mit 2014   introduction to open id connect and o-auth 2
Mit 2014 introduction to open id connect and o-auth 2
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorization
 
An Introduction to OAuth2
An Introduction to OAuth2An Introduction to OAuth2
An Introduction to OAuth2
 
CIS14: Consolidating Authorization for API and Web SSO using OpenID Connect
CIS14: Consolidating Authorization for API and Web SSO using OpenID ConnectCIS14: Consolidating Authorization for API and Web SSO using OpenID Connect
CIS14: Consolidating Authorization for API and Web SSO using OpenID Connect
 
JWT SSO Inbound Authenticator
JWT SSO Inbound AuthenticatorJWT SSO Inbound Authenticator
JWT SSO Inbound Authenticator
 
2016 pycontw web api authentication
2016 pycontw web api authentication 2016 pycontw web api authentication
2016 pycontw web api authentication
 
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
 
#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2
#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2
#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2
 
An Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices WorldAn Authentication and Authorization Architecture for a Microservices World
An Authentication and Authorization Architecture for a Microservices World
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for Beginners
 
Authentication and Authorization Architecture in the MEAN Stack
Authentication and Authorization Architecture in the MEAN StackAuthentication and Authorization Architecture in the MEAN Stack
Authentication and Authorization Architecture in the MEAN Stack
 
CIS 2012 - Going Mobile with PingFederate and OAuth 2
CIS 2012 - Going Mobile with PingFederate and OAuth 2CIS 2012 - Going Mobile with PingFederate and OAuth 2
CIS 2012 - Going Mobile with PingFederate and OAuth 2
 
OAuth2 + API Security
OAuth2 + API SecurityOAuth2 + API Security
OAuth2 + API Security
 

Similar to Protecting web APIs with OAuth 2.0

Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 

Similar to Protecting web APIs with OAuth 2.0 (20)

2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...
2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...
2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...
 
Protecting your APIs with Doorkeeper and OAuth 2.0
Protecting your APIs with Doorkeeper and OAuth 2.0Protecting your APIs with Doorkeeper and OAuth 2.0
Protecting your APIs with Doorkeeper and OAuth 2.0
 
OpenID Connect Explained
OpenID Connect ExplainedOpenID Connect Explained
OpenID Connect Explained
 
Oauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
 
OAuth2
OAuth2OAuth2
OAuth2
 
Oauth Nightmares Abstract OAuth Nightmares
Oauth Nightmares Abstract OAuth Nightmares Oauth Nightmares Abstract OAuth Nightmares
Oauth Nightmares Abstract OAuth Nightmares
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
Accessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) webAccessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) web
 
Microsoft Graph API Delegated Permissions
Microsoft Graph API Delegated PermissionsMicrosoft Graph API Delegated Permissions
Microsoft Graph API Delegated Permissions
 
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID ConnectDemystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
 
OAuth 2
OAuth 2OAuth 2
OAuth 2
 
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...
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
 
.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
 
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
Microservice security with spring security 5.1,Oauth 2.0 and open id connect Microservice security with spring security 5.1,Oauth 2.0 and open id connect
Microservice security with spring security 5.1,Oauth 2.0 and open id connect
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0
 
2019 - Nova Code Camp - AuthZ fundamentals with ASP.NET Core
2019 - Nova Code Camp - AuthZ fundamentals with ASP.NET Core2019 - Nova Code Camp - AuthZ fundamentals with ASP.NET Core
2019 - Nova Code Camp - AuthZ fundamentals with ASP.NET Core
 
OAuth2 Introduction
OAuth2 IntroductionOAuth2 Introduction
OAuth2 Introduction
 
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
 
(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview(1) OAuth 2.0 Overview
(1) OAuth 2.0 Overview
 

More from Vladimir Dzhuvinov

Plovdev 2013: How to be a better programmer, beyond programming
Plovdev 2013: How to be a better programmer, beyond programmingPlovdev 2013: How to be a better programmer, beyond programming
Plovdev 2013: How to be a better programmer, beyond programming
Vladimir Dzhuvinov
 
Binding components, events + data sources in HTML + JS
Binding components, events + data sources in HTML + JSBinding components, events + data sources in HTML + JS
Binding components, events + data sources in HTML + JS
Vladimir Dzhuvinov
 

More from Vladimir Dzhuvinov (7)

Криптография за уеб и мобилни разработчици
Криптография за уеб и мобилни разработчициКриптография за уеб и мобилни разработчици
Криптография за уеб и мобилни разработчици
 
New money
New moneyNew money
New money
 
Mind patterns and anti-patterns
Mind patterns and anti-patternsMind patterns and anti-patterns
Mind patterns and anti-patterns
 
Cross-domain requests with CORS
Cross-domain requests with CORSCross-domain requests with CORS
Cross-domain requests with CORS
 
JSON Web Tokens (JWT)
JSON Web Tokens (JWT)JSON Web Tokens (JWT)
JSON Web Tokens (JWT)
 
Plovdev 2013: How to be a better programmer, beyond programming
Plovdev 2013: How to be a better programmer, beyond programmingPlovdev 2013: How to be a better programmer, beyond programming
Plovdev 2013: How to be a better programmer, beyond programming
 
Binding components, events + data sources in HTML + JS
Binding components, events + data sources in HTML + JSBinding components, events + data sources in HTML + JS
Binding components, events + data sources in HTML + JS
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

Protecting web APIs with OAuth 2.0

  • 1. Protecting web APIs with OAuth 2.0 Vladimir Dzhuvinov
  • 2. Bearer Token Your cool web API
  • 3. HTTPS request with a bearer token GET /client-reg HTTP/1.1 Host: c2id.com Authorization: Bearer ztucZS1ZyFKgh0tUEruUtiSTXhnexmd6 type token value
  • 4. Successful HTTP response HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store Pragma: no-cache { … }
  • 5. On missing token HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer
  • 6. On invalid / expired token HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer error=”invalid_token”
  • 7. On token with insufficient privileges HTTP/1.1 403 Forbidden WWW-Authenticate: Bearer error=”insufficient_scope”
  • 8. To learn more about bearer token usage See RFC 6750 [ http://tools.ietf.org/html/rfc6750 ]
  • 9. How does your web API decode the access tokens? Your W eb API
  • 10. Typical authorisation attributes associated with an access token ● Scope: e.g. read, write, admin... ● Expiration time ● User ID ● Client ID ● Issuer
  • 11. The 2 possible token encodings ● Self-contained: – Require RSA signature verification, < 1 ms – Scale extremely well ● Identifier-based: – Require web API lookup, ~100+ ms – Don't scale well, avoid
  • 12. JSON Web Tokens (JWT) eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJzY3AiOlsib3BlbmlkIiwiZW1haWwiLCJwcm 9maWxlIl0sImV4cCI6MTQxNDA2NTEzNCwic3ViIjoiYWxpY2UiLCJpc3MiOiJodHRw OlwvXC9sb2NhbGhvc3Q6ODA4MFwvYzJpZCIsImlhdCI6MTQxNDA2NDUzNCwiY2l kIjoiMDAwMTIzIn0.fBZW6U9r7M53fwhoEtC9Bxi8U1ytQvpy8pmHylvvvhEZimluNkw mDXWIoHuXIgX9ZfqMp9layftbFE7DVeo3wDpGNM9UtOo8Ccpv7rKrcN60ai6G2hop e7sCRvWTqYx2g8Mk7UOT061Feei7RMYFekO5pFPxSDiKyHCQjbkU Syntax: BASE64URL(header) + “.” + BASE64URL(JSON-claims) + “.” + BASE64URL(RSA-signature)
  • 13. JSON Web Tokens (JWT) Header { "alg": "RS256", "kid": "1" } Claims { "sub": "alice", "cid": "000123", "iss": "https://connect2id.com", "exp": 1414065134, "iat": 1414064534, "scp": [ "read", "write", "admin" ] } Signature (RSA) fBZW6U9r7M53fwh­oEtC9 Bxi8U1ytQvpy8pmHylvvvhEZimlu­NkwmDXWIoHuXIgX9ZfqMp9layftbFE7DVeo­3wDpGNM9UtOo8Cc
  • 14. To learn more about JWT See draft-ietf-oauth-json-web-token-29 [ http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-29 ]
  • 15. The ultimate Java library for JWT http://connect2id.com/products/nimbus-jose-jwt Thousands of deployments, tens of reviewers and contributors Connect2id, Mitre Corp, Microsoft, EA, Square, Zendesk, CertiVox, Harvard Medical Schools, unnamed banks, etc.
  • 16. Who issues the access tokens?
  • 17. Your authorisation server Authenticates users and clients, issues tokens OAuth 2.0 server mobile app web app native app Web API Web API Web API Web APIs service requests, need only understand access tokens
  • 18. The OAuth 2.0 grants ● Authorisation code – require browser for end-user interaction ● Implicit – for browser (JS) based apps ● Password – for native apps ● Client credentials – for clients acting on their own behalf ● Assertions: – SAML 2.0 Bearer – JWT Bearer
  • 19. To learn more about OAuth 2.0 See RFC 6749 [ http://tools.ietf.org/html/rfc6749 ]
  • 20. OpenID Connect ● Identity layer on top of the OAuth 2.0 framework ● The server issues an ID token in addition to the access token: – The ID token is a signed JWT with claims: ● Subject – the end-user ID ● Issuer – the authority ● Issue and expiration date ● Audience – the intended recipients ● Authentication strength and methods
  • 21. ID token claims { "sub" : "alice", "iss" : "https://connect2id.com", "iat" : 1414076589, "exp" : 1414077489, "aud" : [ "000123" ], "ip_address" : "10.20.30.40", "acr" : "1", "amr" : [ "ldap" ] }
  • 22. To learn more about OpenID Connect See OpenID Connect 1.0 Core OpenID Connect 1.0 Discovery OpenID Connect 1.0 Dynamic Registration OpenID Connect 1.0 Session Management [ http://openid.net/connect/ ]