SlideShare a Scribd company logo
1 of 43
Download to read offline
By: Edward Chan
Using JSON Web Tokens
for REST Authentication
Introduction
Edward Chan
@edwardchiapet
linkedin.com/in/edwardchan1350
drupal.org/u/edwardchiapet
Edward is an NYC-based Drupal Developer at Mediacurrent. He
started working with Drupal in 2012 and has experience building
Drupal sites in D6/7/8. He just recently became interested in
decoupled architecture and has experience building and using Drupal
as a backend service. He maintains the Quill and Autocomplete Deluxe
modules.
Drupal Developer
2
github.com/edwardchan
About
3
Mediacurrent helps organizations build highly
impactful, elegantly designed Drupal websites that
achieve the strategic results they need.
● Single-source provider
● Specializing in Drupal since 2007
● Headquartered in Atlanta, GA
● Team of 70+ Drupal Experts including
development, design and strategy
● Clients include: Large Enterprise and
high-profile global brands
Style Guide
Agenda
Introduction to JSON Web Tokens (JWT)
Authenticating REST in Drupal
Comparing JWTs with other methods4
3
2
1
4
How It Works
JSON Web Tokens in Decoupled Architecture
5
● Separation of concerns
● True statelessness
● Flexibility
Introduction to JSON Web Tokens (JWT)
Introduction to JSON Web Tokens (JWT)1
What is JSON Web Token (JWT)?
7
“JSON Web Tokens are an open, industry standard RFC 7519 method that defines a
compact and self-contained way for securely transmitting information between parties
as a JSON object. This information can be verified and trusted because it is digitally
signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private
key pair using RSA...”
- https://jwt.io/introduction
Introduction to JSON Web Tokens (JWT)
What is JSON Web Token (JWT)?
8
● Simply a string in the format of header.payload.signature
● A means of representing claims to be transferred between two parties.
● Intended for space-constrained environments such as HTTP Authorization
headers and URI query parameters.
● Digitally-signed - information is verified and trusted.
Introduction to JSON Web Tokens (JWT)
What is JSON Web Token (JWT)?
9
● A JWT is a type of either JSON Web Signature (JWS) or JSON Web Encryption
(JWE).
● The “claims” in a JWT are encoded as a JSON object that it is digitally-signed using
JWS and/or encrypted using JWE.
● JWS is used in most cases.
● The suggested/formal pronunciation of JWT is “jot”.
Introduction to JSON Web Tokens (JWT)
JSON Web Token Structure
10
Introduction to JSON Web Tokens (JWT)
JSON Web Token Structure
11
Introduction to JSON Web Tokens (JWT)
Header .
Payload .
Signature
JSON Web Token Structure - Header
12
Introduction to JSON Web Tokens (JWT)
● Contains information about how the JWT should be computed.
● Typically contains:
○ “typ” - type of the token (“JWT”)
○ “alg” - signing hashing algorithm being used to sign or encrypt the JWT - such as HMAC SHA256 or RSA
● Example:
JSON Web Token Structure - Payload
13
Introduction to JSON Web Tokens (JWT)
● Contains the “claims set”, which is information we want to transmit and other information about the token.
● Types of claims:
○ Reserved - predefined claims that are recommended.
○ Public - claims that we create ourselves
○ Private - custom claims that are usually more specific to the application you’re connecting to
● A list of predefined claims can be found in the IANA JSON Web Token Registry
(https://www.iana.org/assignments/jwt/jwt.xhtml).
JSON Web Token Structure - Payload
14
Introduction to JSON Web Tokens (JWT)
exp Expiration time
iss Token issuer
iat Time the JWT was issued
nbf Not before
Some reserved claim names:
JSON Web Token Structure - Signature
15
Introduction to JSON Web Tokens (JWT)
● Used to verify that the sender of the JWT is legitimate and to ensure that the
message was not changed or altered along the way.
● Value is generated by hashing the following using the signing algorithm specified in
the “header”:
○ base64UrlEncode(header) + “.” + base64UrlEncode(payload)
○ a “secret” (held by the server and will be used to verify existing tokens and
sign new ones)
JSON Web Token Structure - Signature
16
Introduction to JSON Web Tokens (JWT)
Example of generating the signature using HMAC SHA256:
var encodedHeader = base64UrlEncode(header);
var encodedPayload = base64UrlEncode(payload);
var signature = base64UrlEncode(HMACSHA256(encodedHeader + “.”
+ encodedPayload, secret));
JSON Web Signature (JWS) Compact Serialization
17
Introduction to JSON Web Tokens (JWT)
Image source: “JWT” Handbook by Sebastián Peyrott
(encoded header)
(encoded payload)
JSON Web Signature (JWS) Compact Serialization
18
Introduction to JSON Web Tokens (JWT)
Image source: “JWT” Handbook by Sebastián Peyrott
(encoded header)
(encoded payload)
JSON Web Signature (JWS) Compact Serialization
19
Introduction to JSON Web Tokens (JWT)
Image source: “JWT” Handbook by Sebastián Peyrott
JSON Web Signature (JWS) Compact Serialization
20
Introduction to JSON Web Tokens (JWT)
Image source: “JWT” Handbook by Sebastián Peyrott
How It Works2
22
Authentication Process
How It Works
23
Authentication Process
How It Works
24
Authentication Process
How It Works
Bouncer with a guest list
(server and a database)
25
Authentication Process
How It Works
Yourself and your ID
(username and password)
26
Authentication Process
How It Works
Identity verified!
(login credentials valid)
27
Authentication Process
How It Works
Wristband
(JWT)
28
Authentication Process
How It Works
29
Authentication Process
How It Works
Bar
(Resource server)
30
Authentication Process
How It Works
Consume API
Resources
31
Authentication Process
How It Works
JWT expires (“exp”)
32
Authentication Process
Image source: https://jwt.io/introduction/
How It Works
33
Authentication Process
How It Works
Image source: https://jwt.io/introduction/
How does JWT protect our data?
34
Introduction to JSON Web Tokens (JWT)
● Used to verify the authenticity of the source that sent the data.
● Short expiry times.
● Retrieving a new JWT requires a valid refresh token.
● A signed JWT does not hide or obscure data in any way
Using JWTs to Authenticate REST in Drupal3
“JSON Web Token Authentication (JWT)” module
36
Using JWTs to Authenticate REST in Drupal
● https://www.drupal.org/project/jwt
● Depends on the “Key” module to manage secret keys.
● “JWT Authentication Issuer” - provides an endpoint to issue JWTs.
● “JWT Authentication Consumer” - authenticates JWTs generated by “JWT Authentication Issuer”.
● Provides 3 events for event subscribers:
○ VALIDATE
Allows for custom validations for a JWT.
○ VALID
Fires after a token has been validated. Subscribers can create new users based on the payload, if necessary.
○ GENERATE
Fires before a new JWT is encoded. Subscribers can add claims to the JWT before it is given to the client.
“JSON Web Token Authentication (JWT)” module
37
Using JWTs to Authenticate REST in Drupal
https://www.mediacurrent.com/blog/using-json-web-tokens-jwt-authenticate-endpoints
JWT Debugger
38
Using JWTs to Authenticate REST in Drupal
● Allows you to see the content of a JWT -
including the claims in the payload.
● You can verify the validity of the token with a
secret.
● Chrome extension!
Comparing JWTs with other methods4
Cookie-based Authentication
40
Comparing JWTs with other methods
JWT advantages
41
Comparing JWTs with other methods
● Stateless
● Scalability
● Digitally-signed
● Performance
● CORS/CSRF
● Mobile-ready
● Decoupled/Decentralized
JWT drawbacks
42
Comparing JWTs with other methods
● Size of token
● Tokens Revocation
● Single-Page Applications
@Mediacurrent Mediacurrent.com
Thank you!
slideshare.net/mediacurrent
https://jwt.io/
https://www.drupal.org/project/jwt
https://www.mediacurrent.com/blog/using-json-web-tokens-jwt-authenticate-endpoints

More Related Content

What's hot

Introduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring SecurityIntroduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring SecurityBruno Henrique Rother
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authenticationjeremysbrown
 
[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokens[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokensOWASP
 
Intro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectIntro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectLiamWadman
 
OAuth 2.0 and OpenId Connect
OAuth 2.0 and OpenId ConnectOAuth 2.0 and OpenId Connect
OAuth 2.0 and OpenId ConnectSaran Doraiswamy
 
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
 
Secure your app with keycloak
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloakGuy Marom
 
OpenID 4 Verifiable Credentials + HAIP (Update)
OpenID 4 Verifiable Credentials + HAIP (Update)OpenID 4 Verifiable Credentials + HAIP (Update)
OpenID 4 Verifiable Credentials + HAIP (Update)Torsten Lodderstedt
 
Introduction to SAML 2.0
Introduction to SAML 2.0Introduction to SAML 2.0
Introduction to SAML 2.0Mika Koivisto
 
Secure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakSecure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakRed Hat Developers
 
An Introduction to OAuth 2
An Introduction to OAuth 2An Introduction to OAuth 2
An Introduction to OAuth 2Aaron Parecki
 
REST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTsREST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTsJon Todd
 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with KeycloakJulien Pivotto
 
Verifiable Credentials, Self Sovereign Identity and DLTs
Verifiable Credentials, Self Sovereign Identity and DLTs Verifiable Credentials, Self Sovereign Identity and DLTs
Verifiable Credentials, Self Sovereign Identity and DLTs Vasiliy Suvorov
 

What's hot (20)

Introduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring SecurityIntroduction to JWT and How to integrate with Spring Security
Introduction to JWT and How to integrate with Spring Security
 
Pentesting jwt
Pentesting jwtPentesting jwt
Pentesting jwt
 
JSON Web Tokens
JSON Web TokensJSON Web Tokens
JSON Web Tokens
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
 
OpenID Connect Explained
OpenID Connect ExplainedOpenID Connect Explained
OpenID Connect Explained
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokens[OPD 2019] Attacking JWT tokens
[OPD 2019] Attacking JWT tokens
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Intro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID ConnectIntro to OAuth2 and OpenID Connect
Intro to OAuth2 and OpenID Connect
 
OAuth 2.0 and OpenId Connect
OAuth 2.0 and OpenId ConnectOAuth 2.0 and OpenId Connect
OAuth 2.0 and OpenId Connect
 
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
 
Secure your app with keycloak
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloak
 
OpenID 4 Verifiable Credentials + HAIP (Update)
OpenID 4 Verifiable Credentials + HAIP (Update)OpenID 4 Verifiable Credentials + HAIP (Update)
OpenID 4 Verifiable Credentials + HAIP (Update)
 
Introduction to SAML 2.0
Introduction to SAML 2.0Introduction to SAML 2.0
Introduction to SAML 2.0
 
Secure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with KeycloakSecure Spring Boot Microservices with Keycloak
Secure Spring Boot Microservices with Keycloak
 
Json web tokens
Json web tokensJson web tokens
Json web tokens
 
An Introduction to OAuth 2
An Introduction to OAuth 2An Introduction to OAuth 2
An Introduction to OAuth 2
 
REST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTsREST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTs
 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
 
Verifiable Credentials, Self Sovereign Identity and DLTs
Verifiable Credentials, Self Sovereign Identity and DLTs Verifiable Credentials, Self Sovereign Identity and DLTs
Verifiable Credentials, Self Sovereign Identity and DLTs
 

Similar to Using JSON Web Tokens for REST Authentication

[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API ManagerWSO2
 
Jwt the complete guide to json web tokens
Jwt  the complete guide to json web tokensJwt  the complete guide to json web tokens
Jwt the complete guide to json web tokensremayssat
 
2016 pycontw web api authentication
2016 pycontw web api authentication 2016 pycontw web api authentication
2016 pycontw web api authentication Micron Technology
 
Microservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFMicroservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFVMware Tanzu
 
Microservices Security Landscape
Microservices Security LandscapeMicroservices Security Landscape
Microservices Security LandscapePrabath Siriwardena
 
5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)Amit Gupta
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5usnyff
 
OAuth and why you should use it
OAuth and why you should use itOAuth and why you should use it
OAuth and why you should use itSergey Podgornyy
 
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"Andreas Falk
 
Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021Leadex Systems
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & EncryptionAaron Zauner
 
Blockcerts: The Open Standard for Blockchain Credentials
Blockcerts: The Open Standard for Blockchain CredentialsBlockcerts: The Open Standard for Blockchain Credentials
Blockcerts: The Open Standard for Blockchain CredentialsSSIMeetup
 
Jwt with flask slide deck - alan swenson
Jwt with flask   slide deck - alan swensonJwt with flask   slide deck - alan swenson
Jwt with flask slide deck - alan swensonJeffrey Clark
 
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWS
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWSI Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWS
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWSApigee | Google Cloud
 
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...Uniface
 

Similar to Using JSON Web Tokens for REST Authentication (20)

[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
 
Jwt the complete guide to json web tokens
Jwt  the complete guide to json web tokensJwt  the complete guide to json web tokens
Jwt the complete guide to json web tokens
 
JWTs and JOSE in a flash
JWTs and JOSE in a flashJWTs and JOSE in a flash
JWTs and JOSE in a flash
 
2016 pycontw web api authentication
2016 pycontw web api authentication 2016 pycontw web api authentication
2016 pycontw web api authentication
 
Microservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCFMicroservices Security Patterns & Protocols with Spring & PCF
Microservices Security Patterns & Protocols with Spring & PCF
 
Microservices Security Landscape
Microservices Security LandscapeMicroservices Security Landscape
Microservices Security Landscape
 
API
APIAPI
API
 
5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)5 easy steps to understanding json web tokens (jwt)
5 easy steps to understanding json web tokens (jwt)
 
Landscape
LandscapeLandscape
Landscape
 
Landscape
LandscapeLandscape
Landscape
 
Json web tokens
Json web tokensJson web tokens
Json web tokens
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5u
 
OAuth and why you should use it
OAuth and why you should use itOAuth and why you should use it
OAuth and why you should use it
 
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"
 
Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021Moscow MuleSoft meetup May 2021
Moscow MuleSoft meetup May 2021
 
Javascript Object Signing & Encryption
Javascript Object Signing & EncryptionJavascript Object Signing & Encryption
Javascript Object Signing & Encryption
 
Blockcerts: The Open Standard for Blockchain Credentials
Blockcerts: The Open Standard for Blockchain CredentialsBlockcerts: The Open Standard for Blockchain Credentials
Blockcerts: The Open Standard for Blockchain Credentials
 
Jwt with flask slide deck - alan swenson
Jwt with flask   slide deck - alan swensonJwt with flask   slide deck - alan swenson
Jwt with flask slide deck - alan swenson
 
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWS
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWSI Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWS
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - JWT, JWE, JWS
 
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
 

More from Mediacurrent

Penn State News: Pivoting to Decoupled Drupal with Gatsby
Penn State News: Pivoting to Decoupled Drupal with GatsbyPenn State News: Pivoting to Decoupled Drupal with Gatsby
Penn State News: Pivoting to Decoupled Drupal with GatsbyMediacurrent
 
Evolving How We Measure Digital Success in Higher Ed
Evolving How We Measure Digital Success in Higher EdEvolving How We Measure Digital Success in Higher Ed
Evolving How We Measure Digital Success in Higher EdMediacurrent
 
Penn State scales static Drupal to new heights
Penn State scales static Drupal to new heightsPenn State scales static Drupal to new heights
Penn State scales static Drupal to new heightsMediacurrent
 
Delivering Meaningful Digital Experiences in Higher Ed
Delivering Meaningful Digital Experiences in Higher EdDelivering Meaningful Digital Experiences in Higher Ed
Delivering Meaningful Digital Experiences in Higher EdMediacurrent
 
Content Strategy: Building Connections with Your Audience
Content Strategy: Building Connections with Your AudienceContent Strategy: Building Connections with Your Audience
Content Strategy: Building Connections with Your AudienceMediacurrent
 
Decoupled Drupal and Gatsby in the Real World
Decoupled Drupal and Gatsby in the Real WorldDecoupled Drupal and Gatsby in the Real World
Decoupled Drupal and Gatsby in the Real WorldMediacurrent
 
A Better Way to Build and Manage Sites with Rain for Drupal 9
A Better Way to Build and Manage Sites with Rain for Drupal 9A Better Way to Build and Manage Sites with Rain for Drupal 9
A Better Way to Build and Manage Sites with Rain for Drupal 9Mediacurrent
 
Drupal Security: What You Need to Know
Drupal Security: What You Need to KnowDrupal Security: What You Need to Know
Drupal Security: What You Need to KnowMediacurrent
 
Leveraging Design Systems to Streamline Web Projects
Leveraging Design Systems to Streamline Web ProjectsLeveraging Design Systems to Streamline Web Projects
Leveraging Design Systems to Streamline Web ProjectsMediacurrent
 
Reimagining Your Higher Ed Web Strategy
Reimagining Your Higher Ed Web StrategyReimagining Your Higher Ed Web Strategy
Reimagining Your Higher Ed Web StrategyMediacurrent
 
How to Digitally Transform Higher Ed with Drupal
How to Digitally Transform Higher Ed with DrupalHow to Digitally Transform Higher Ed with Drupal
How to Digitally Transform Higher Ed with DrupalMediacurrent
 
Is my website accessible? Common mistakes (and how to fix them)
Is my website accessible? Common mistakes (and how to fix them)Is my website accessible? Common mistakes (and how to fix them)
Is my website accessible? Common mistakes (and how to fix them)Mediacurrent
 
Managing Images In Large Scale Drupal 8 & 9 Websites
Managing Images In Large Scale Drupal 8 & 9 WebsitesManaging Images In Large Scale Drupal 8 & 9 Websites
Managing Images In Large Scale Drupal 8 & 9 WebsitesMediacurrent
 
Paragraphs v Layout Builder - The Final Showdown
Paragraphs v Layout Builder - The Final ShowdownParagraphs v Layout Builder - The Final Showdown
Paragraphs v Layout Builder - The Final ShowdownMediacurrent
 
MagMutual.com: On the JAMStack with Gatsby and Drupal 8
 MagMutual.com: On the JAMStack with Gatsby and Drupal 8 MagMutual.com: On the JAMStack with Gatsby and Drupal 8
MagMutual.com: On the JAMStack with Gatsby and Drupal 8Mediacurrent
 
Creating an Organizational Culture of Giving Back to Drupal
Creating an Organizational Culture of Giving Back to DrupalCreating an Organizational Culture of Giving Back to Drupal
Creating an Organizational Culture of Giving Back to DrupalMediacurrent
 
Level Up Your Team: Front-End Development Best Practices
Level Up Your Team: Front-End Development Best PracticesLevel Up Your Team: Front-End Development Best Practices
Level Up Your Team: Front-End Development Best PracticesMediacurrent
 
Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9Mediacurrent
 
How to Prove Marketing ROI: Overcoming Digital Marketing Challenges
How to Prove Marketing ROI: Overcoming Digital Marketing ChallengesHow to Prove Marketing ROI: Overcoming Digital Marketing Challenges
How to Prove Marketing ROI: Overcoming Digital Marketing ChallengesMediacurrent
 
Prepare Your Drupal 9 Action Plan
Prepare Your Drupal 9 Action Plan Prepare Your Drupal 9 Action Plan
Prepare Your Drupal 9 Action Plan Mediacurrent
 

More from Mediacurrent (20)

Penn State News: Pivoting to Decoupled Drupal with Gatsby
Penn State News: Pivoting to Decoupled Drupal with GatsbyPenn State News: Pivoting to Decoupled Drupal with Gatsby
Penn State News: Pivoting to Decoupled Drupal with Gatsby
 
Evolving How We Measure Digital Success in Higher Ed
Evolving How We Measure Digital Success in Higher EdEvolving How We Measure Digital Success in Higher Ed
Evolving How We Measure Digital Success in Higher Ed
 
Penn State scales static Drupal to new heights
Penn State scales static Drupal to new heightsPenn State scales static Drupal to new heights
Penn State scales static Drupal to new heights
 
Delivering Meaningful Digital Experiences in Higher Ed
Delivering Meaningful Digital Experiences in Higher EdDelivering Meaningful Digital Experiences in Higher Ed
Delivering Meaningful Digital Experiences in Higher Ed
 
Content Strategy: Building Connections with Your Audience
Content Strategy: Building Connections with Your AudienceContent Strategy: Building Connections with Your Audience
Content Strategy: Building Connections with Your Audience
 
Decoupled Drupal and Gatsby in the Real World
Decoupled Drupal and Gatsby in the Real WorldDecoupled Drupal and Gatsby in the Real World
Decoupled Drupal and Gatsby in the Real World
 
A Better Way to Build and Manage Sites with Rain for Drupal 9
A Better Way to Build and Manage Sites with Rain for Drupal 9A Better Way to Build and Manage Sites with Rain for Drupal 9
A Better Way to Build and Manage Sites with Rain for Drupal 9
 
Drupal Security: What You Need to Know
Drupal Security: What You Need to KnowDrupal Security: What You Need to Know
Drupal Security: What You Need to Know
 
Leveraging Design Systems to Streamline Web Projects
Leveraging Design Systems to Streamline Web ProjectsLeveraging Design Systems to Streamline Web Projects
Leveraging Design Systems to Streamline Web Projects
 
Reimagining Your Higher Ed Web Strategy
Reimagining Your Higher Ed Web StrategyReimagining Your Higher Ed Web Strategy
Reimagining Your Higher Ed Web Strategy
 
How to Digitally Transform Higher Ed with Drupal
How to Digitally Transform Higher Ed with DrupalHow to Digitally Transform Higher Ed with Drupal
How to Digitally Transform Higher Ed with Drupal
 
Is my website accessible? Common mistakes (and how to fix them)
Is my website accessible? Common mistakes (and how to fix them)Is my website accessible? Common mistakes (and how to fix them)
Is my website accessible? Common mistakes (and how to fix them)
 
Managing Images In Large Scale Drupal 8 & 9 Websites
Managing Images In Large Scale Drupal 8 & 9 WebsitesManaging Images In Large Scale Drupal 8 & 9 Websites
Managing Images In Large Scale Drupal 8 & 9 Websites
 
Paragraphs v Layout Builder - The Final Showdown
Paragraphs v Layout Builder - The Final ShowdownParagraphs v Layout Builder - The Final Showdown
Paragraphs v Layout Builder - The Final Showdown
 
MagMutual.com: On the JAMStack with Gatsby and Drupal 8
 MagMutual.com: On the JAMStack with Gatsby and Drupal 8 MagMutual.com: On the JAMStack with Gatsby and Drupal 8
MagMutual.com: On the JAMStack with Gatsby and Drupal 8
 
Creating an Organizational Culture of Giving Back to Drupal
Creating an Organizational Culture of Giving Back to DrupalCreating an Organizational Culture of Giving Back to Drupal
Creating an Organizational Culture of Giving Back to Drupal
 
Level Up Your Team: Front-End Development Best Practices
Level Up Your Team: Front-End Development Best PracticesLevel Up Your Team: Front-End Development Best Practices
Level Up Your Team: Front-End Development Best Practices
 
Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9Best Practices for Moving to Drupal 9
Best Practices for Moving to Drupal 9
 
How to Prove Marketing ROI: Overcoming Digital Marketing Challenges
How to Prove Marketing ROI: Overcoming Digital Marketing ChallengesHow to Prove Marketing ROI: Overcoming Digital Marketing Challenges
How to Prove Marketing ROI: Overcoming Digital Marketing Challenges
 
Prepare Your Drupal 9 Action Plan
Prepare Your Drupal 9 Action Plan Prepare Your Drupal 9 Action Plan
Prepare Your Drupal 9 Action Plan
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Using JSON Web Tokens for REST Authentication

  • 1. By: Edward Chan Using JSON Web Tokens for REST Authentication
  • 2. Introduction Edward Chan @edwardchiapet linkedin.com/in/edwardchan1350 drupal.org/u/edwardchiapet Edward is an NYC-based Drupal Developer at Mediacurrent. He started working with Drupal in 2012 and has experience building Drupal sites in D6/7/8. He just recently became interested in decoupled architecture and has experience building and using Drupal as a backend service. He maintains the Quill and Autocomplete Deluxe modules. Drupal Developer 2 github.com/edwardchan
  • 3. About 3 Mediacurrent helps organizations build highly impactful, elegantly designed Drupal websites that achieve the strategic results they need. ● Single-source provider ● Specializing in Drupal since 2007 ● Headquartered in Atlanta, GA ● Team of 70+ Drupal Experts including development, design and strategy ● Clients include: Large Enterprise and high-profile global brands
  • 4. Style Guide Agenda Introduction to JSON Web Tokens (JWT) Authenticating REST in Drupal Comparing JWTs with other methods4 3 2 1 4 How It Works
  • 5. JSON Web Tokens in Decoupled Architecture 5 ● Separation of concerns ● True statelessness ● Flexibility Introduction to JSON Web Tokens (JWT)
  • 6. Introduction to JSON Web Tokens (JWT)1
  • 7. What is JSON Web Token (JWT)? 7 “JSON Web Tokens are an open, industry standard RFC 7519 method that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA...” - https://jwt.io/introduction Introduction to JSON Web Tokens (JWT)
  • 8. What is JSON Web Token (JWT)? 8 ● Simply a string in the format of header.payload.signature ● A means of representing claims to be transferred between two parties. ● Intended for space-constrained environments such as HTTP Authorization headers and URI query parameters. ● Digitally-signed - information is verified and trusted. Introduction to JSON Web Tokens (JWT)
  • 9. What is JSON Web Token (JWT)? 9 ● A JWT is a type of either JSON Web Signature (JWS) or JSON Web Encryption (JWE). ● The “claims” in a JWT are encoded as a JSON object that it is digitally-signed using JWS and/or encrypted using JWE. ● JWS is used in most cases. ● The suggested/formal pronunciation of JWT is “jot”. Introduction to JSON Web Tokens (JWT)
  • 10. JSON Web Token Structure 10 Introduction to JSON Web Tokens (JWT)
  • 11. JSON Web Token Structure 11 Introduction to JSON Web Tokens (JWT) Header . Payload . Signature
  • 12. JSON Web Token Structure - Header 12 Introduction to JSON Web Tokens (JWT) ● Contains information about how the JWT should be computed. ● Typically contains: ○ “typ” - type of the token (“JWT”) ○ “alg” - signing hashing algorithm being used to sign or encrypt the JWT - such as HMAC SHA256 or RSA ● Example:
  • 13. JSON Web Token Structure - Payload 13 Introduction to JSON Web Tokens (JWT) ● Contains the “claims set”, which is information we want to transmit and other information about the token. ● Types of claims: ○ Reserved - predefined claims that are recommended. ○ Public - claims that we create ourselves ○ Private - custom claims that are usually more specific to the application you’re connecting to ● A list of predefined claims can be found in the IANA JSON Web Token Registry (https://www.iana.org/assignments/jwt/jwt.xhtml).
  • 14. JSON Web Token Structure - Payload 14 Introduction to JSON Web Tokens (JWT) exp Expiration time iss Token issuer iat Time the JWT was issued nbf Not before Some reserved claim names:
  • 15. JSON Web Token Structure - Signature 15 Introduction to JSON Web Tokens (JWT) ● Used to verify that the sender of the JWT is legitimate and to ensure that the message was not changed or altered along the way. ● Value is generated by hashing the following using the signing algorithm specified in the “header”: ○ base64UrlEncode(header) + “.” + base64UrlEncode(payload) ○ a “secret” (held by the server and will be used to verify existing tokens and sign new ones)
  • 16. JSON Web Token Structure - Signature 16 Introduction to JSON Web Tokens (JWT) Example of generating the signature using HMAC SHA256: var encodedHeader = base64UrlEncode(header); var encodedPayload = base64UrlEncode(payload); var signature = base64UrlEncode(HMACSHA256(encodedHeader + “.” + encodedPayload, secret));
  • 17. JSON Web Signature (JWS) Compact Serialization 17 Introduction to JSON Web Tokens (JWT) Image source: “JWT” Handbook by Sebastián Peyrott (encoded header) (encoded payload)
  • 18. JSON Web Signature (JWS) Compact Serialization 18 Introduction to JSON Web Tokens (JWT) Image source: “JWT” Handbook by Sebastián Peyrott (encoded header) (encoded payload)
  • 19. JSON Web Signature (JWS) Compact Serialization 19 Introduction to JSON Web Tokens (JWT) Image source: “JWT” Handbook by Sebastián Peyrott
  • 20. JSON Web Signature (JWS) Compact Serialization 20 Introduction to JSON Web Tokens (JWT) Image source: “JWT” Handbook by Sebastián Peyrott
  • 24. 24 Authentication Process How It Works Bouncer with a guest list (server and a database)
  • 25. 25 Authentication Process How It Works Yourself and your ID (username and password)
  • 26. 26 Authentication Process How It Works Identity verified! (login credentials valid)
  • 27. 27 Authentication Process How It Works Wristband (JWT)
  • 29. 29 Authentication Process How It Works Bar (Resource server)
  • 30. 30 Authentication Process How It Works Consume API Resources
  • 31. 31 Authentication Process How It Works JWT expires (“exp”)
  • 32. 32 Authentication Process Image source: https://jwt.io/introduction/ How It Works
  • 33. 33 Authentication Process How It Works Image source: https://jwt.io/introduction/
  • 34. How does JWT protect our data? 34 Introduction to JSON Web Tokens (JWT) ● Used to verify the authenticity of the source that sent the data. ● Short expiry times. ● Retrieving a new JWT requires a valid refresh token. ● A signed JWT does not hide or obscure data in any way
  • 35. Using JWTs to Authenticate REST in Drupal3
  • 36. “JSON Web Token Authentication (JWT)” module 36 Using JWTs to Authenticate REST in Drupal ● https://www.drupal.org/project/jwt ● Depends on the “Key” module to manage secret keys. ● “JWT Authentication Issuer” - provides an endpoint to issue JWTs. ● “JWT Authentication Consumer” - authenticates JWTs generated by “JWT Authentication Issuer”. ● Provides 3 events for event subscribers: ○ VALIDATE Allows for custom validations for a JWT. ○ VALID Fires after a token has been validated. Subscribers can create new users based on the payload, if necessary. ○ GENERATE Fires before a new JWT is encoded. Subscribers can add claims to the JWT before it is given to the client.
  • 37. “JSON Web Token Authentication (JWT)” module 37 Using JWTs to Authenticate REST in Drupal https://www.mediacurrent.com/blog/using-json-web-tokens-jwt-authenticate-endpoints
  • 38. JWT Debugger 38 Using JWTs to Authenticate REST in Drupal ● Allows you to see the content of a JWT - including the claims in the payload. ● You can verify the validity of the token with a secret. ● Chrome extension!
  • 39. Comparing JWTs with other methods4
  • 41. JWT advantages 41 Comparing JWTs with other methods ● Stateless ● Scalability ● Digitally-signed ● Performance ● CORS/CSRF ● Mobile-ready ● Decoupled/Decentralized
  • 42. JWT drawbacks 42 Comparing JWTs with other methods ● Size of token ● Tokens Revocation ● Single-Page Applications