SlideShare a Scribd company logo
1
Basics of OAuth 2.0 and OpenID Connect
Andreas Falk / Novatec Consulting
Our #AppSec Offerings:
▪ OAuth 2.0 & OpenID Connect Trainings and Consulting
▪ Security for Developers Trainings
https://www.novatec-gmbh.de/en/consulting/agile-security
About Me
2
Andreas Falk
Novatec Consulting
(Germany)
andreas.falk@novatec-gmbh.de
@andifalk
RFC 6749: OAuth 2.0 Authorization Framework
RFC 6750: OAuth 2.0 Bearer Token Usage
3
Introduction to OAuth 2.0
Do you like it implementing your own Authentication?
4
Password
Policies
MFA
Secure Password
Storage
Different
Clients
Brute Force
Prevention
Reset
Password
Process
Using Multiple Services before OAuth 2.0
5
Client
Resource Owner
(i.e. the user)
Resource Server
1.Resource owner
authenticates to the client
2.Client requests the protected resource
Credentials
Credentials
“The OAuth 2.0 authorization framework enables a
third-party application to obtain limited access to
an HTTP service, either on behalf of a resource
owner by orchestrating an approval interaction between the
resource owner and the HTTP service, or by allowing the
third-party application to obtain access on its own behalf
”
RFC 6749: OAuth 2.0
6
OAuth 2.0 Roles
7
Client
Resource Owner Authorization Server
Access Token
Resource Server
Basic OAuth 2.0 Protocol Flow
8
Client
Resource Owner Authorization Server
Access Token
Resource Server
1.Resource owner authorizes the client
2.Client receives authorization grant
3.Client exchanges grant for access token
4.Client requests the protected resource
Protocol Flow (1): Resource owner authorizes client
9
Resource Owner Authorization Server
1.Resource owner authorizes the client
Protocol Flow (2): Client receives authorization grant
10
Client
Resource Owner Authorization Server
1.Resource owner authorizes the client
2.Client receives authorization grant
Authorization grant:
▪ Credential representing the resource
owner's authorization
▪ Exchange for access token
Protocol Flow (3): Client exchanges grant for access token
11
Client
Resource Owner Authorization Server
Access Token
1.Resource owner authorizes the client
2.Client receives authorization grant
3.Client exchanges grant for access token
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "2YotnFZFEjr1zC",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "tGzv3JOkF0XG5Q"
}
Protocol Flow: Client requests the protected resource
12
Client
Access Token
Resource Server
4.Client requests the protected resource
GET /resource HTTP/1.1
Host: server.example.com
Authorization: Bearer 2YotnFZFEjr1zC
OAuth 2.0 Protocol Endpoints
13
Client
Resource Owner
Resource Server
Authorization ServerToken
Endpoint
Authorization
Endpoint
Token Introspection
Endpoint
Resource Owner Client Authorization
Retrieve Authorization Grant
Exchange Authorization Grant
into Access Token
Validate Access Token
Authorization Grant Types
14
2007
OAuth 1.0
Protocol
2010
RFC 5849: The
OAuth 1.0a
Protocol
2012
RFC 6749:
The OAuth 2.0
Authorization
Framework
2013
RFC 6819:
OAuth 2.0
Threat
Model
2015
RFC 7519:
JSON Web
Token
(JWT)
2015
RFC 7636:
Proof Key for
Code Exchange
(PKCE)
2019-2020
OAuth 2.0
Security Best
Current
Practice
OAuth History
15
2020,...
OAuth 2.1
TxAuth
▪ Authorization Code grant is extended with PKCE
▪ Implicit grant is omitted from the spec
▪ RO Password Credentials grant is omitted from the spec
▪ Redirect URIs must be compared by exact string matching
▪ Refresh tokens must be sender-constrained or one-time use
▪ Bearer token must not be sent in the query string of URIs
The OAuth 2.1 Authorization Framework
16
https://datatracker.ietf.org/doc/draft-parecki-oauth-v2-1/
“OAuth 2.1” Authorization Grant Types
17
Resource
Owner
Client Type Authorization Grant Refresh
Token
Web Client (Confidential) Authorization Code + PKCE
Mobile Client (Public) Authorization Code + PKCE
SPA Client (Public) Authorization Code + PKCE
Resource Owner Client
(Confidential)
Client Credentials
https://datatracker.ietf.org/doc/draft-ietf-oauth-security-topics
https://datatracker.ietf.org/doc/draft-parecki-oauth-v2-1
▪ RFC 7636: PKCE = Proof Key for Code Exchange (“pixy”)
▪ Mitigates authorization code interception attack
▪ Public clients cannot keep static secrets (“client_secret”)
▪ PKCE adds dynamic secret instead:
− Cryptographically random key: The “Code Verifier”
− Hashed code verifier (SHA-256): The “Code Challenge”
Authorization Code + PKCE Grant Type
18
https://tools.ietf.org/html/rfc7636
OpenID Connect Foundation
19
OpenID Connect 1.0
OAuth 2.0 is NOT an Authentication Protocol!
20
OAuth 2.0 is not an authentication protocol
OAuth 2.0 vs. OpenID Connect 1.0
21
Hotel
Valet
Parking
Identification
Permission /
Delegation
OpenID
Connect
1.0
OAuth
2.0
OpenID Connect 1.0 Standards Layer
22
JSON Web Algorithms (JWA)
JSON Web Signature (JWS) JSON Web Encryption (JWE) JSON Web Key (JWK)
JSON Web Token (JWT)
Javascript Object Signing and Encryption (JOSE)
OAuth 2.0 Authorization Framework (RFC 6749)
OpenID Connect 1.0
▪ Based on OAuth 2.0
▪ Additions:
− ID Token (JWT format is Mandatory)
− User Info Endpoint (Mandatory)
− Hybrid Grant Flow (Mandatory)
− OpenID Provider Configuration Information
(Discovery, Optional)
https://openid.net/specs/openid-connect-core-1_0.html
https://openid.net/specs/openid-connect-registration-1_0.html
https://openid.net/specs/openid-connect-discovery-1_0.html
OpenID Connect 1.0 (OIDC)
23
{
"alg": "RS256",
"typ": "JWT",
"kid": "lp_FcMZ8D7U6EEUCiZyWAF21NcwjX_ddwJ5a3eCPMwQ"
}
JSON Web Token (JWT) - Decoded Form
24
{
"exp": 1571745342,
"iat": 1571745042,
"iss": "http://localhost:8080/auth/realms/workshop",
"aud": ["library-service","account"],
"sub": "08d3bcaa-5ffd-4b8d-909e-bb567881384b"
}
HEADER
PAYLOAD
OpenID Connect 1.0: Access Token Types
25
JWT Token (Self-contained) Opaque Token (Reference)
Offline-Validation (Signature/Expiration) Validation call to introspection-endpoint
Contains all required information Additional call to get required information
Protocol agnostic Bound to Http
Cannot be revoked May be revoked
Mandatory for Id Tokens Must not be used for Id Tokens
May be used for Access Tokens May be used for Access Tokens
▪ Use OpenID Connect for Authentication
▪ Authorization Grant Types
− With End User: Use Authorization Code + PKCE
− Without End User: Use Client Credentials
▪ Do NOT use Implicit or Resource Owner Password Grants
▪ ID Token must be JWT, Access Token may be JWT
▪ Always validate Tokens and keep Lifetime short
OAuth 2.0 and OpenID Connect: Summary
26
Thank You very much!
Questions?
27
Novatec Consulting GmbH
Dieselstraße 18/1
D-70771 Leinfelden-Echterdingen
T. +49 711 22040-700
info@novatec-gmbh.de
www.novatec-gmbh.de
28
Managing Consultant
Andreas Falk
Mobil: +49 151 46146778
E-Mail: andreas.falk@novatec-gmbh.de
OpenID Connect Implementations
29
▪ RedHat/JBoss Keycloak (https://www.keycloak.org)
▪ Auth0 (https://auth0.com)
▪ Okta (https://www.okta.com)
▪ ForgeRock (https://www.forgerock.com/platform/identity-management)
▪ CloudFoundry UAA (https://github.com/cloudfoundry/uaa)
▪ PingFederate
(https://www.pingidentity.com/en/platform/single-sign-on/sso-overview.html)
▪ Azure Active Directory
(https://azure.microsoft.com/en-us/services/active-directory)
▪ ...
See: https://openid.net/developers/certified/#OPServices
OpenID Connect Identity Providers
30
▪ oidc-client (Javascript) https://github.com/IdentityModel/oidc-client-js
▪ angular-oauth2-oidc (Typescript)
https://github.com/manfredsteyer/angular-oauth2-oidc
▪ angular-auth-oidc-client (Typescript)
https://github.com/damienbod/angular-auth-oidc-client
▪ IdentityModel.OidcClient (C#/.Net)
https://github.com/IdentityModel/IdentityModel.OidcClient
▪ Nimbus OAuth 2.0 SDK (Java)
https://connect2id.com/products/nimbus-oauth-openid-connect-sdk
▪ OIDC RP library (Python) https://github.com/openid/JWTConnect-Python-OidcRP
▪ ...
See: https://openid.net/developers/certified/#OPServices
OpenID Connect Libraries
31
Books and Online References
32
▪ Justin Richer et.al: OAuth2 in Action (Manning, 2017, ISBN 978-1617293276)
▪ Michael Schwartz et.al: Securing the Perimeter (Apress, 2018, ISBN
978-1484226001)
▪ RFC 6749: The OAuth 2.0 Authorization Framework
▪ RFC 6750: OAuth 2.0 Bearer Token Usage
▪ RFC 6819: OAuth 2.0 Threat Model and Security Considerations
▪ RFC 7636: Proof Key for Code Exchange ("Pixy")
▪ OpenID Connect Core 1.0 Specification
▪ OpenID Connect Dynamic Client Registration 1.0
▪ OpenID Connect Discovery 1.0
▪ RFC 7519: JSON Web Token (JWT)
▪ JSON Web Token Best Current Practices
Books and Online References (1)
33
▪ Why you should stop using the OAuth implicit grant
▪ OAuth 2.0 Security Best Current Practice
▪ OAuth 2.0 for Browser-Based Apps
▪ OAuth 2.0 Mutual TLS Client Authentication and Certificate-Bound Access Tokens
▪ JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens
▪ OAuth 2.0 Token Exchange
Books and Online References (2)
34
▪ Resource Indicators for OAuth 2.0
▪ Spring Security 5.2 Reference Documentation
▪ Microservices Security Patterns & Protocols with Spring Security (Devoxx Video)
▪ Microservices Security Patterns & Protocols (SpringOne Platform 2019 Video)
▪ How to secure your Spring apps with Keycloak by Thomas Darimont (Video)
Books and Online References (3)
35

More Related Content

PDF
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
PPTX
Cryptography 101 for Java developers
PDF
Introduction to JWT and How to integrate with Spring Security
PDF
Nk API - examples
PDF
RoadSec 2017 - Trilha AppSec - APIs Authorization
PPTX
Hyperledger fabric
PPTX
Secure Authorization for your Printer: The OAuth Device Flow (DevSum 2018)
PPT
Cordacon 2018 - Cordentity - Hyperledger Indy + Corda
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
Cryptography 101 for Java developers
Introduction to JWT and How to integrate with Spring Security
Nk API - examples
RoadSec 2017 - Trilha AppSec - APIs Authorization
Hyperledger fabric
Secure Authorization for your Printer: The OAuth Device Flow (DevSum 2018)
Cordacon 2018 - Cordentity - Hyperledger Indy + Corda

What's hot (20)

PPTX
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
PPTX
Microservices security - jpmc tech fest 2018
PPTX
Cryptography 101 for_java_developers, Fall 2019
PDF
Outsmarting Smart Contracts - an essential walkthrough a blockchain security ...
PDF
Applications and deployment patterns of o auth and open id connect
PPTX
Cryptography 101 for Java Developers - Devoxx 2019
PPTX
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
PDF
introduction to jsrsasign
PPTX
Cryptography 101 for Java Developers - JavaZone2019
ODP
Blockchain Introduction
PPTX
U2F/FIDO2 implementation of YubiKey
PDF
Hacking intranet websites
PDF
How to get rid of terraform plan diffs
PPTX
Authenticating Angular Apps with JWT
PPTX
Authorization for the IoT: The OAuth Device Flow (European Identity & Cloud C...
PDF
OAuth and why you should use it
PPTX
XSS: From alert(1) to crypto mining malware
PPTX
Modern Authentication with OpenID Connect and IdentityServer 4 (umBristol - J...
PPTX
Cargo Cult Security UJUG Sep2015
PPTX
Microservices Security landscape
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Microservices security - jpmc tech fest 2018
Cryptography 101 for_java_developers, Fall 2019
Outsmarting Smart Contracts - an essential walkthrough a blockchain security ...
Applications and deployment patterns of o auth and open id connect
Cryptography 101 for Java Developers - Devoxx 2019
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
introduction to jsrsasign
Cryptography 101 for Java Developers - JavaZone2019
Blockchain Introduction
U2F/FIDO2 implementation of YubiKey
Hacking intranet websites
How to get rid of terraform plan diffs
Authenticating Angular Apps with JWT
Authorization for the IoT: The OAuth Device Flow (European Identity & Cloud C...
OAuth and why you should use it
XSS: From alert(1) to crypto mining malware
Modern Authentication with OpenID Connect and IdentityServer 4 (umBristol - J...
Cargo Cult Security UJUG Sep2015
Microservices Security landscape
Ad

Similar to AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect" (20)

PDF
iMasters Intercon 2016 - Identity within Microservices
PDF
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
PDF
Seamless OAuth2.0 and OpenID Connect in VAST
PDF
OpenID for SSI
PDF
2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...
PDF
The OpenID Connect Protocol
PDF
OpenID Connect Explained
PPTX
OAuth2 para desarrolladores
PDF
[LDAPCon 2015] The OpenID Connect Protocol
PDF
#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2
PDF
Keeping Pace with OAuth’s Evolving Security Practices.pdf
PPTX
Adding Identity Management and Access Control to your App
PPTX
Adding identity management and access control to your app
PDF
2016 pycontw web api authentication
PDF
OpenID and OAuth
PDF
OpenID Connect primer
PDF
JavaOne 2014 - Securing RESTful Resources with OAuth2
PDF
INTERFACE by apidays - TxAuth: the future of OAuth? by Dick Hardt
PDF
Accessing APIs using OAuth on the federated (WordPress) web
PDF
Introduction to OAuth
iMasters Intercon 2016 - Identity within Microservices
InterCon 2016 - Segurança de identidade digital levando em consideração uma a...
Seamless OAuth2.0 and OpenID Connect in VAST
OpenID for SSI
2019 - Tech Talk DC - Token-based security for web applications using OAuth2 ...
The OpenID Connect Protocol
OpenID Connect Explained
OAuth2 para desarrolladores
[LDAPCon 2015] The OpenID Connect Protocol
#5 WSO2 Masterclassitalia - WSO2 Identity Server, un approccio OAUTH2
Keeping Pace with OAuth’s Evolving Security Practices.pdf
Adding Identity Management and Access Control to your App
Adding identity management and access control to your app
2016 pycontw web api authentication
OpenID and OAuth
OpenID Connect primer
JavaOne 2014 - Securing RESTful Resources with OAuth2
INTERFACE by apidays - TxAuth: the future of OAuth? by Dick Hardt
Accessing APIs using OAuth on the federated (WordPress) web
Introduction to OAuth
Ad

More from Andreas Falk (6)

PDF
Sicher in die Cloud mit Angular und Spring Boot (Karlsruher Entwicklertag 2017)
PDF
Manage distributed configuration and secrets with spring cloud and vault (Spr...
PDF
JAX 2017 - Sicher in die Cloud mit Angular und Spring Boot
PDF
OWASP German Day 2016 - Sicher in die Cloud mit Angular 2 und Spring Boot
PDF
OWASP AppSecEu 2016 Rome - Building secure cloud native apps
PDF
Cloud Foundry Meetup Stuttgart 2017 - Spring Cloud Development
Sicher in die Cloud mit Angular und Spring Boot (Karlsruher Entwicklertag 2017)
Manage distributed configuration and secrets with spring cloud and vault (Spr...
JAX 2017 - Sicher in die Cloud mit Angular und Spring Boot
OWASP German Day 2016 - Sicher in die Cloud mit Angular 2 und Spring Boot
OWASP AppSecEu 2016 Rome - Building secure cloud native apps
Cloud Foundry Meetup Stuttgart 2017 - Spring Cloud Development

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
Programs and apps: productivity, graphics, security and other tools
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Chapter 3 Spatial Domain Image Processing.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"

  • 1. 1 Basics of OAuth 2.0 and OpenID Connect Andreas Falk / Novatec Consulting
  • 2. Our #AppSec Offerings: ▪ OAuth 2.0 & OpenID Connect Trainings and Consulting ▪ Security for Developers Trainings https://www.novatec-gmbh.de/en/consulting/agile-security About Me 2 Andreas Falk Novatec Consulting (Germany) andreas.falk@novatec-gmbh.de @andifalk
  • 3. RFC 6749: OAuth 2.0 Authorization Framework RFC 6750: OAuth 2.0 Bearer Token Usage 3 Introduction to OAuth 2.0
  • 4. Do you like it implementing your own Authentication? 4 Password Policies MFA Secure Password Storage Different Clients Brute Force Prevention Reset Password Process
  • 5. Using Multiple Services before OAuth 2.0 5 Client Resource Owner (i.e. the user) Resource Server 1.Resource owner authenticates to the client 2.Client requests the protected resource Credentials Credentials
  • 6. “The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf ” RFC 6749: OAuth 2.0 6
  • 7. OAuth 2.0 Roles 7 Client Resource Owner Authorization Server Access Token Resource Server
  • 8. Basic OAuth 2.0 Protocol Flow 8 Client Resource Owner Authorization Server Access Token Resource Server 1.Resource owner authorizes the client 2.Client receives authorization grant 3.Client exchanges grant for access token 4.Client requests the protected resource
  • 9. Protocol Flow (1): Resource owner authorizes client 9 Resource Owner Authorization Server 1.Resource owner authorizes the client
  • 10. Protocol Flow (2): Client receives authorization grant 10 Client Resource Owner Authorization Server 1.Resource owner authorizes the client 2.Client receives authorization grant Authorization grant: ▪ Credential representing the resource owner's authorization ▪ Exchange for access token
  • 11. Protocol Flow (3): Client exchanges grant for access token 11 Client Resource Owner Authorization Server Access Token 1.Resource owner authorizes the client 2.Client receives authorization grant 3.Client exchanges grant for access token HTTP/1.1 200 OK Content-Type: application/json { "access_token": "2YotnFZFEjr1zC", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "tGzv3JOkF0XG5Q" }
  • 12. Protocol Flow: Client requests the protected resource 12 Client Access Token Resource Server 4.Client requests the protected resource GET /resource HTTP/1.1 Host: server.example.com Authorization: Bearer 2YotnFZFEjr1zC
  • 13. OAuth 2.0 Protocol Endpoints 13 Client Resource Owner Resource Server Authorization ServerToken Endpoint Authorization Endpoint Token Introspection Endpoint Resource Owner Client Authorization Retrieve Authorization Grant Exchange Authorization Grant into Access Token Validate Access Token
  • 15. 2007 OAuth 1.0 Protocol 2010 RFC 5849: The OAuth 1.0a Protocol 2012 RFC 6749: The OAuth 2.0 Authorization Framework 2013 RFC 6819: OAuth 2.0 Threat Model 2015 RFC 7519: JSON Web Token (JWT) 2015 RFC 7636: Proof Key for Code Exchange (PKCE) 2019-2020 OAuth 2.0 Security Best Current Practice OAuth History 15 2020,... OAuth 2.1 TxAuth
  • 16. ▪ Authorization Code grant is extended with PKCE ▪ Implicit grant is omitted from the spec ▪ RO Password Credentials grant is omitted from the spec ▪ Redirect URIs must be compared by exact string matching ▪ Refresh tokens must be sender-constrained or one-time use ▪ Bearer token must not be sent in the query string of URIs The OAuth 2.1 Authorization Framework 16 https://datatracker.ietf.org/doc/draft-parecki-oauth-v2-1/
  • 17. “OAuth 2.1” Authorization Grant Types 17 Resource Owner Client Type Authorization Grant Refresh Token Web Client (Confidential) Authorization Code + PKCE Mobile Client (Public) Authorization Code + PKCE SPA Client (Public) Authorization Code + PKCE Resource Owner Client (Confidential) Client Credentials https://datatracker.ietf.org/doc/draft-ietf-oauth-security-topics https://datatracker.ietf.org/doc/draft-parecki-oauth-v2-1
  • 18. ▪ RFC 7636: PKCE = Proof Key for Code Exchange (“pixy”) ▪ Mitigates authorization code interception attack ▪ Public clients cannot keep static secrets (“client_secret”) ▪ PKCE adds dynamic secret instead: − Cryptographically random key: The “Code Verifier” − Hashed code verifier (SHA-256): The “Code Challenge” Authorization Code + PKCE Grant Type 18 https://tools.ietf.org/html/rfc7636
  • 20. OAuth 2.0 is NOT an Authentication Protocol! 20 OAuth 2.0 is not an authentication protocol
  • 21. OAuth 2.0 vs. OpenID Connect 1.0 21 Hotel Valet Parking Identification Permission / Delegation OpenID Connect 1.0 OAuth 2.0
  • 22. OpenID Connect 1.0 Standards Layer 22 JSON Web Algorithms (JWA) JSON Web Signature (JWS) JSON Web Encryption (JWE) JSON Web Key (JWK) JSON Web Token (JWT) Javascript Object Signing and Encryption (JOSE) OAuth 2.0 Authorization Framework (RFC 6749) OpenID Connect 1.0
  • 23. ▪ Based on OAuth 2.0 ▪ Additions: − ID Token (JWT format is Mandatory) − User Info Endpoint (Mandatory) − Hybrid Grant Flow (Mandatory) − OpenID Provider Configuration Information (Discovery, Optional) https://openid.net/specs/openid-connect-core-1_0.html https://openid.net/specs/openid-connect-registration-1_0.html https://openid.net/specs/openid-connect-discovery-1_0.html OpenID Connect 1.0 (OIDC) 23
  • 24. { "alg": "RS256", "typ": "JWT", "kid": "lp_FcMZ8D7U6EEUCiZyWAF21NcwjX_ddwJ5a3eCPMwQ" } JSON Web Token (JWT) - Decoded Form 24 { "exp": 1571745342, "iat": 1571745042, "iss": "http://localhost:8080/auth/realms/workshop", "aud": ["library-service","account"], "sub": "08d3bcaa-5ffd-4b8d-909e-bb567881384b" } HEADER PAYLOAD
  • 25. OpenID Connect 1.0: Access Token Types 25 JWT Token (Self-contained) Opaque Token (Reference) Offline-Validation (Signature/Expiration) Validation call to introspection-endpoint Contains all required information Additional call to get required information Protocol agnostic Bound to Http Cannot be revoked May be revoked Mandatory for Id Tokens Must not be used for Id Tokens May be used for Access Tokens May be used for Access Tokens
  • 26. ▪ Use OpenID Connect for Authentication ▪ Authorization Grant Types − With End User: Use Authorization Code + PKCE − Without End User: Use Client Credentials ▪ Do NOT use Implicit or Resource Owner Password Grants ▪ ID Token must be JWT, Access Token may be JWT ▪ Always validate Tokens and keep Lifetime short OAuth 2.0 and OpenID Connect: Summary 26
  • 27. Thank You very much! Questions? 27
  • 28. Novatec Consulting GmbH Dieselstraße 18/1 D-70771 Leinfelden-Echterdingen T. +49 711 22040-700 info@novatec-gmbh.de www.novatec-gmbh.de 28 Managing Consultant Andreas Falk Mobil: +49 151 46146778 E-Mail: andreas.falk@novatec-gmbh.de
  • 30. ▪ RedHat/JBoss Keycloak (https://www.keycloak.org) ▪ Auth0 (https://auth0.com) ▪ Okta (https://www.okta.com) ▪ ForgeRock (https://www.forgerock.com/platform/identity-management) ▪ CloudFoundry UAA (https://github.com/cloudfoundry/uaa) ▪ PingFederate (https://www.pingidentity.com/en/platform/single-sign-on/sso-overview.html) ▪ Azure Active Directory (https://azure.microsoft.com/en-us/services/active-directory) ▪ ... See: https://openid.net/developers/certified/#OPServices OpenID Connect Identity Providers 30
  • 31. ▪ oidc-client (Javascript) https://github.com/IdentityModel/oidc-client-js ▪ angular-oauth2-oidc (Typescript) https://github.com/manfredsteyer/angular-oauth2-oidc ▪ angular-auth-oidc-client (Typescript) https://github.com/damienbod/angular-auth-oidc-client ▪ IdentityModel.OidcClient (C#/.Net) https://github.com/IdentityModel/IdentityModel.OidcClient ▪ Nimbus OAuth 2.0 SDK (Java) https://connect2id.com/products/nimbus-oauth-openid-connect-sdk ▪ OIDC RP library (Python) https://github.com/openid/JWTConnect-Python-OidcRP ▪ ... See: https://openid.net/developers/certified/#OPServices OpenID Connect Libraries 31
  • 32. Books and Online References 32
  • 33. ▪ Justin Richer et.al: OAuth2 in Action (Manning, 2017, ISBN 978-1617293276) ▪ Michael Schwartz et.al: Securing the Perimeter (Apress, 2018, ISBN 978-1484226001) ▪ RFC 6749: The OAuth 2.0 Authorization Framework ▪ RFC 6750: OAuth 2.0 Bearer Token Usage ▪ RFC 6819: OAuth 2.0 Threat Model and Security Considerations ▪ RFC 7636: Proof Key for Code Exchange ("Pixy") ▪ OpenID Connect Core 1.0 Specification ▪ OpenID Connect Dynamic Client Registration 1.0 ▪ OpenID Connect Discovery 1.0 ▪ RFC 7519: JSON Web Token (JWT) ▪ JSON Web Token Best Current Practices Books and Online References (1) 33
  • 34. ▪ Why you should stop using the OAuth implicit grant ▪ OAuth 2.0 Security Best Current Practice ▪ OAuth 2.0 for Browser-Based Apps ▪ OAuth 2.0 Mutual TLS Client Authentication and Certificate-Bound Access Tokens ▪ JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens ▪ OAuth 2.0 Token Exchange Books and Online References (2) 34
  • 35. ▪ Resource Indicators for OAuth 2.0 ▪ Spring Security 5.2 Reference Documentation ▪ Microservices Security Patterns & Protocols with Spring Security (Devoxx Video) ▪ Microservices Security Patterns & Protocols (SpringOne Platform 2019 Video) ▪ How to secure your Spring apps with Keycloak by Thomas Darimont (Video) Books and Online References (3) 35