$ whoamimichael.herman
$ whoamimichael.herman
$ whoamimichael.herman
By the end of this training, you will be able to:
By the end of this training, you will be able to:
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
Describe the various OAuth 2.0 grant types and when it's appropriate to use each
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
Describe the various OAuth 2.0 grant types and when it's appropriate to use each
Implement an OAuth 2.0 server with Node
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
Describe the various OAuth 2.0 grant types and when it's appropriate to use each
Implement an OAuth 2.0 server with Node
Explain what OpenID Connect is and how it works with OAuth 2.0
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
Describe the various OAuth 2.0 grant types and when it's appropriate to use each
Implement an OAuth 2.0 server with Node
Explain what OpenID Connect is and how it works with OAuth 2.0
Implement OpenID Connect with Node
By the end of this training, you will be able to:
Describe the difference between authentication and authorization
Explain what OAuth 2.0 is and how it differs from OAuth 1.0
Describe the various OAuth 2.0 grant types and when it's appropriate to use each
Implement an OAuth 2.0 server with Node
Explain what OpenID Connect is and how it works with OAuth 2.0
Implement OpenID Connect with Node
Develop a Client app to interact with an OAuth 2.0 and OpenID Connect server
"Who are you and what are you allowed to do?"
"Who are you and what are you allowed to do?"
"Who are you and what are you allowed to do?"
"Who are you and what are you allowed to do?"
Oauth is an open standard for authorization.
"An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications."
Oauth is an open standard for authorization.
"An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications."
It's all about delegation:
Oauth is an open standard for authorization.
"An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications."
It's all about delegation:
Oauth is an open standard for authorization.
"An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications."
It's all about delegation:
Compared to OAuth 1.0, OAuth 2.0:
Term | Definition |
---|---|
Resource Owner (aka User) | End user who authorizes an application to access their account |
Client (aka Consumer) | Application that accesses protected resources on behalf of the user |
Authorization Server | Server which grants Access Tokens after the user authorizes the application |
Resource Server | Restricted resource / API |
Access Token | Token used to access restricted resources |
Authorization Code | Intermediate token returned to the client, after the user authorization step, which the client exchanges it for an Access Token |
Grant | Method of acquiring an Access Token |
Grant Type | Use Case | Link |
---|---|---|
Authorization Code | Server-side web apps | 4.1 |
Implicit | Single Page Apps (SPAs) | 4.2 |
Resource Owner Credentials (Password) | Trusted first party clients | 4.3 |
Client Credentials | Machine-to-machine | 4.4 |
Grant Type | Use Case | Link |
---|---|---|
Authorization Code | Server-side web apps | 4.1 |
Implicit | Single Page Apps (SPAs) | 4.2 |
Resource Owner Credentials (Password) | Trusted first party clients | 4.3 |
Client Credentials | Machine-to-machine | 4.4 |
Which grant should you use? Decision tree
First vs third party client?
Grant Type | Use Case | Link |
---|---|---|
Authorization Code | Server-side web apps | 4.1 |
Implicit | Single Page Apps (SPAs) | 4.2 |
Resource Owner Credentials (Password) | Trusted first party clients | 4.3 |
Client Credentials | Machine-to-machine | 4.4 |
Which grant should you use? Decision tree
First vs third party client?
Grant Type | Use Case | Link |
---|---|---|
Authorization Code | Server-side web apps | 4.1 |
Implicit | Single Page Apps (SPAs) | 4.2 |
Resource Owner Credentials (Password) | Trusted first party clients | 4.3 |
Client Credentials | Machine-to-machine | 4.4 |
Which grant should you use? Decision tree
First vs third party client?
Source: A Guide to OAuth 2.0 Grants
[Step 1] Client redirects the Resource Owner to the Authorization Server
[Step 1] Client redirects the Resource Owner to the Authorization Server
[Step 2] Resource Owner grants authorization
[Step 3] Authorization Server redirects the Resource Owner back to the Client with an Authorization Code
[Step 4] Client exchanges Authorization Code for Access Token
[Step 4] Client exchanges Authorization Code for Access Token
[Step 5] Authorization Server grants Access Token
[Step 6] Client uses the Access Token to access protected resources, from the Resource Server, on behalf of the Resource Owner
[Step 6] Client uses the Access Token to access protected resources, from the Resource Server, on behalf of the Resource Owner
What's different about this flow for the other grant types—Implicit, Resource Owner Credentials, Client Credentials? Understanding OAuth2
The User would provide their credentials directly to the Client app.
The User would provide their credentials directly to the Client app.
The User would provide their credentials directly to the Client app.
The User would provide their credentials directly to the Client app.
Introduced in December 2007 to prevent the Client application from having to directly handle the User's credentials.
The User would provide their credentials directly to the Client app.
Introduced in December 2007 to prevent the Client application from having to directly handle the User's credentials.
First came out in April 2010.
First came out in April 2010.
What's the difference between authentication and authorization?
What is OAuth?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
🤔
You should:
Clone down the node-oauth-openid repo and check out the base tag:
$ git clone https://github.com/mjhea0/node-oauth-openid$ git checkout -b base
Clone down the node-oauth-openid repo and check out the base tag:
$ git clone https://github.com/mjhea0/node-oauth-openid$ git checkout -b base
Install the dependencies:
$ npm install
Clone down the node-oauth-openid repo and check out the base tag:
$ git clone https://github.com/mjhea0/node-oauth-openid$ git checkout -b base
Install the dependencies:
$ npm install
Run the server:
$ npm start
Ensure the server is up and running at http://localhost:3001/ and http://localhost:3001/ping.
Clone down the node-oauth-openid repo and check out the base tag:
$ git clone https://github.com/mjhea0/node-oauth-openid$ git checkout -b base
Install the dependencies:
$ npm install
Run the server:
$ npm start
Ensure the server is up and running at http://localhost:3001/ and http://localhost:3001/ping.
Let's review app.js together...
/oauth/authorize
- GET
/oauth/authorize
- GET
/oauth/authorize/dialog
- GET
/oauth/authorize
- GET
/oauth/authorize/dialog
- GET
/oauth/authorize/dialog
- POST
/oauth/token
- POST
/oauth/token
- POST
/oauth/userinfo
- GET
Authorization: Bearer <token>
)true
false
user
- user ID, email, client IDclient
- client ID, name, redirect URIauthCode
- code, created at, consumed, user IDaccessToken
- token, created at, expires in, token type (e.g., bearer), user ID, refresh token (optional)user
- user ID, email, client IDclient
- client ID, name, redirect URIauthCode
- code, created at, consumed, user IDaccessToken
- token, created at, expires in, token type (e.g., bearer), user ID, refresh token (optional)user
- user ID, email, client IDclient
- client ID, name, redirect URIauthCode
- code, created at, consumed, user IDaccessToken
- token, created at, expires in, token type (e.g., bearer), user ID, refresh token (optional)Bearer Tokens are probably the most popular type of Access Token. They must be unique, nonsequential, and nonguessable.
user
- user ID, email, client IDclient
- client ID, name, redirect URIauthCode
- code, created at, consumed, user IDaccessToken
- token, created at, expires in, token type (e.g., bearer), user ID, refresh token (optional)Bearer Tokens are probably the most popular type of Access Token. They must be unique, nonsequential, and nonguessable.
Authorization: Bearer 4ae6ce68-4c59-4313-94e2-fcc2932cf5ca
Content-Type: application/x-www-form-urlencoded
, access_token=mF_9.B5f-4.1JqM
resource?access_token=mF_9.B5f-4.1JqM
So, we need to implement the following:
user
, client
, authCode
, accessToken
/oauth/authorize
(GET), /oauth/authorize/dialog
(GET and POST), /oauth/token
(POST), /oauth/userinfo
(GET)So, we need to implement the following:
user
, client
, authCode
, accessToken
/oauth/authorize
(GET), /oauth/authorize/dialog
(GET and POST), /oauth/token
(POST), /oauth/userinfo
(GET)Let's skip user log in for now and get something working. What else can we punt in order to get a working prototype up and running?
So, we need to implement the following:
user
, client
, authCode
, accessToken
/oauth/authorize
(GET), /oauth/authorize/dialog
(GET and POST), /oauth/token
(POST), /oauth/userinfo
(GET)Let's skip user log in for now and get something working. What else can we punt in order to get a working prototype up and running?
Where do we begin?
What's the difference between authentication and authorization?
What is OAuth?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
🤔
OpenID Connect (or OIDC), the latest version of OpenID, is a standard for authentication, issued by the OpenID Foundation in February 2014.
OpenID Connect (or OIDC), the latest version of OpenID, is a standard for authentication, issued by the OpenID Foundation in February 2014.
OpenID Connect (or OIDC), the latest version of OpenID, is a standard for authentication, issued by the OpenID Foundation in February 2014.
OpenID Connect (or OIDC), the latest version of OpenID, is a standard for authentication, issued by the OpenID Foundation in February 2014.
OpenID Connect extends OAuth 2.0, adding an extra layer for handling user authentication. It's a superset of OAuth 2.0.
With OpenID Connect, the token
endpoint returns an ID Token instead of an Access Token.
OpenID Connect (or OIDC), the latest version of OpenID, is a standard for authentication, issued by the OpenID Foundation in February 2014.
OpenID Connect extends OAuth 2.0, adding an extra layer for handling user authentication. It's a superset of OAuth 2.0.
With OpenID Connect, the token
endpoint returns an ID Token instead of an Access Token.
The ID Token is a JSON Web Token that contains information about the authenticated user.
A JSON Web Token (or JWT) is a JSON-based standard for securely transmitting information. They can signed (JWS) or encrypted (JWE).
A JSON Web Token (or JWT) is a JSON-based standard for securely transmitting information. They can signed (JWS) or encrypted (JWE).
A JSON Web Token (or JWT) is a JSON-based standard for securely transmitting information. They can signed (JWS) or encrypted (JWE).
httpOnly
and secure flags.A JSON Web Token (or JWT) is a JSON-based standard for securely transmitting information. They can signed (JWS) or encrypted (JWE).
httpOnly
and secure flags.scope
to the /authorize
endpointAdd scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
What are JWT Claims?
Which claims are required? Which claims should we use?
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
What are JWT Claims?
Which claims are required? Which claims should we use?
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
What are JWT Claims?
Which claims are required? Which claims should we use?
Always use HTTPS!
Issue short lived bearer tokens
Add scope
to the /authorize
endpoint
Create (via jsonwebtoken) then return an ID Token in the /token
endpoint
Modify the /userinfo
to decode the ID Token and return user info
What are JWT Claims?
Which claims are required? Which claims should we use?
Always use HTTPS!
Issue short lived bearer tokens
Don't pass bearer token in page URLs
Let's spin up a new Express application to serve as the Client.
Let's spin up a new Express application to serve as the Client.
/
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
If the User authorization is successful, the User is redirect back to the Client, to the redirect URI, with the Authorization Code and State
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
If the User authorization is successful, the User is redirect back to the Client, to the redirect URI, with the Authorization Code and State
With the Authorization Code in hand, request Access Token
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
If the User authorization is successful, the User is redirect back to the Client, to the redirect URI, with the Authorization Code and State
With the Authorization Code in hand, request Access Token
If the Authorization Code is valid, an ID Token is sent back
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
If the User authorization is successful, the User is redirect back to the Client, to the redirect URI, with the Authorization Code and State
With the Authorization Code in hand, request Access Token
If the Authorization Code is valid, an ID Token is sent back
Store the ID token
Let's spin up a new Express application to serve as the Client.
Display "Authorize" button on page load to /
On button click, redirect User (with Grant type, client ID, redirect URI, Scope, and State) to the Authorization Server's /oauth/authorize
endpoint
If the User authorization is successful, the User is redirect back to the Client, to the redirect URI, with the Authorization Code and State
With the Authorization Code in hand, request Access Token
If the Authorization Code is valid, an ID Token is sent back
Store the ID token
On requests to restricted resources, send the ID Token in the request header
What's the difference between authentication and authorization?
What is OAuth?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
What is OpenID Connect?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
What is OpenID Connect?
How does OpenID connect work with OAuth 2.0?
What's the difference between authentication and authorization?
What is OAuth?
Describe the various OAuth 2.0 grant types
How does the grant type affect the OAuth 2.0 authorization flow?
What is OpenID Connect?
How does OpenID connect work with OAuth 2.0?
🤔
TODO
sAnything else?
TODO
sAnything else?
TODO
sAnything else?
TODO
sAnything else?
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |