SlideShare a Scribd company logo
JSON WEB TOKEN
Ivan Rosolen
Graduado em Sistemas de Informação
Pós-graduado em Gerência de Projetos
Desenvolvedor a 15+ anos
Autor de vários PHPT (testes para o PHP)
Entusiasta de novas tecnologias
Head of Innovation @ Arizona
CTO @ Mokation
@ivanrosolen
Authentication
- Form Request Post/Get
- OAuth
- Key/Hash
- Credenciais em plain text
- Session Cookies
- Data is stored in plain text on the server
- Filesystem read/write requests
- Distributed/clustered applications
- Redis/Sticky sessions
API
- Stateless authentication (simplifies horizontal scaling)
- Prevent (mitigate) Cross-Site Request Forgery (CSRF)
attacks.
- Security (https)
- Authorization: Bearer
- Authentication vs. Authorization
- 401 unauthorized / 403 forbidden
- JWT != ACL
JOSE
- JWT
- JWS
- JWA
- JWK
- JWE
JSON Object Signing and Encryption
Advantages
- JSON Web Tokens work across different programming languages
- JWTs are self-contained
- JWTs can be passed around easily and secure
- Better control like “one time token” to forgot password, confirm
user, request rates, access, etc.
- One token to rule them all (Stateless)
Anatomy
header.claims.signature
Header
{
"typ": "JWT",
"alg": "HS256"
}
Claims
- iss: The issuer of the token
- sub: The subject of the token
- aud: The audience of the token
- exp: This will probably be the registered claim most often used. This will define the expiration
in NumericDate value. The expiration MUST be after the current date/time.
- nbf: Defines the time before which the JWT MUST NOT be accepted for processing
- iat: The time the JWT was issued. Can be used to determine the age of the JWT
- jti: Unique identifier for the JWT. Can be used to prevent the JWT from being replayed. This is
helpful for a one time use token.
http://www.slideshare.net/lcobucci/jwt-to-authentication-and-beyond
Payload / Claims
{
"iss": "ivanrosolen.com",
"exp": 1300819380,
"name": "Ivan Rosolen",
"admin": true
}
JWT
eyJ0eXAiOiAiSldUIiwiYWxnIjogIkhTMjU2In0=
.
eyJpc3MiOiAiaXZhbnJvc29sZW4uY29tIiwiZXhwIjogMTMwM
DgxOTM4MCwibmFtZSI6ICJJdmFuIFJvc29sZW4iLCJhZG1pbiI
6IHRydWV9
.
JWS
- header
- claims
payload
base64(header) . base64(claims)
JWA
- secret (hmac sha256, rsa256 ....)
- encrypt payload with key ‘Xuplau’
Signature
var encodedString = base64UrlEncode(header) + "."
+ base64UrlEncode(payload);
HMACSHA256(encodedString, 'Xuplau');
JWT
eyJ0eXAiOiAiSldUIiwiYWxnIjogIkhTMjU2In0=
.
eyJpc3MiOiAiaXZhbnJvc29sZW4uY29tIiwiZXhwIjogMTMwM
DgxOTM4MCwibmFtZSI6ICJJdmFuIFJvc29sZW4iLCJhZG1pbiI
6IHRydWV9
.
M2FjZTM0M2ZiNjhhMzBiOWNiYTkxN2U1Zjk4YjUxOWYzMT
Y3NGZlMmU4MTIzYjU1NTRkMjNlNjYzOTkyZGU2Nw==
Warning!
Code
Autenticação com Json Web Token (JWT)
Autenticação com Json Web Token (JWT)
Github
- Session
- JWT
- JOSE
DEMO
Refs
Github
https://github.com/ivanrosolen/crud-demo
JWT
https://github.com/dwyl/learn-json-web-tokens
http://jwt.io
https://developer.atlassian.com/static/connect/docs/latest/concepts/understanding-jwt.html
http://stackoverflow.com/questions/20588467/how-to-do-stateless-session-less-cookie-less-authentication
Talks
http://www.slideshare.net/erickt86/secureapi
http://www.slideshare.net/lcobucci/jwt-to-authentication-and-beyond
Luís Otávio Cobucci Oblonczyk
https://github.com/lcobucci/jwt
https://github.com/Ocramius/PSR7Session
????
OBRIGADO!
Visite phpsp.org.br

More Related Content

What's hot (20)

PDF
Jwt Security
Seid Yassin
 
PPTX
Pentesting jwt
Jaya Kumar Kondapalli
 
PPTX
Token Based Authentication Systems
Hüseyin BABAL
 
PDF
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
PPTX
Dom based xss
Lê Giáp
 
PDF
WPNYC: Moving your site to HTTPS
Paul Schreiber
 
PDF
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
Thomas Witt
 
PDF
Applying Security Controls on REST APIs
Erick Belluci Tedeschi
 
PPTX
JWTs and JOSE in a flash
Evan J Johnson (Not a CISSP)
 
PDF
Insecurity-In-Security version.1 (2010)
Abhishek Kumar
 
PDF
Protecting Java Microservices: Best Practices and Strategies
Rodrigo Cândido da Silva
 
PPT
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
PPTX
Java Session
AathikaJava
 
PDF
Insecurity-In-Security version.2 (2011)
Abhishek Kumar
 
PPTX
HTTPS
R.K. University
 
PDF
Building Your First MongoDB App
Henrik Ingo
 
PPTX
Back to Basics: My First MongoDB Application
MongoDB
 
PPTX
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
ODP
WS-* with WCF
ppcanodehuelva
 
Jwt Security
Seid Yassin
 
Pentesting jwt
Jaya Kumar Kondapalli
 
Token Based Authentication Systems
Hüseyin BABAL
 
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
Dom based xss
Lê Giáp
 
WPNYC: Moving your site to HTTPS
Paul Schreiber
 
JavaScript Security: Mastering Cross Domain Communications in complex JS appl...
Thomas Witt
 
Applying Security Controls on REST APIs
Erick Belluci Tedeschi
 
JWTs and JOSE in a flash
Evan J Johnson (Not a CISSP)
 
Insecurity-In-Security version.1 (2010)
Abhishek Kumar
 
Protecting Java Microservices: Best Practices and Strategies
Rodrigo Cândido da Silva
 
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
Java Session
AathikaJava
 
Insecurity-In-Security version.2 (2011)
Abhishek Kumar
 
Building Your First MongoDB App
Henrik Ingo
 
Back to Basics: My First MongoDB Application
MongoDB
 
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
WS-* with WCF
ppcanodehuelva
 

Similar to Autenticação com Json Web Token (JWT) (20)

PDF
RoadSec 2017 - Trilha AppSec - APIs Authorization
Erick Belluci Tedeschi
 
PPTX
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface
 
PPTX
Building Secure User Interfaces With JWTs
robertjd
 
PDF
Securing Web Applications with Token Authentication
Stormpath
 
PPTX
Securing Single Page Applications with Token Based Authentication
Stefan Achtsnit
 
PPTX
OWASP Free Training - SF2014 - Keary and Manico
Eoin Keary
 
PPTX
Token Authentication for Java Applications
Stormpath
 
PPT
Web Attacks - Top threats - 2010
Shreeraj Shah
 
PPT
HTML5 hacking
Blueinfy Solutions
 
PDF
Jwt the complete guide to json web tokens
remayssat
 
PPTX
Identity and Access Management - RSA 2017 Security Foundations Seminar
Brian Campbell
 
PPT
Starwest 2008
Caleb Sima
 
PDF
Authorization Using JWTs
ForgeRock Identity Tech Talks
 
PPTX
Spa Secure Coding Guide
Geoffrey Vandiest
 
PDF
2011 and still bruteforcing - OWASP Spain
Christian Martorella
 
PPTX
JWT Authentication with AngularJS
robertjd
 
PPTX
Roberto Bicchierai - Defending web applications from attacks
Pietro Polsinelli
 
PDF
Javascript Object Signing & Encryption
Aaron Zauner
 
PDF
Jwt with flask slide deck - alan swenson
Jeffrey Clark
 
PPTX
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
RoadSec 2017 - Trilha AppSec - APIs Authorization
Erick Belluci Tedeschi
 
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Uniface
 
Building Secure User Interfaces With JWTs
robertjd
 
Securing Web Applications with Token Authentication
Stormpath
 
Securing Single Page Applications with Token Based Authentication
Stefan Achtsnit
 
OWASP Free Training - SF2014 - Keary and Manico
Eoin Keary
 
Token Authentication for Java Applications
Stormpath
 
Web Attacks - Top threats - 2010
Shreeraj Shah
 
HTML5 hacking
Blueinfy Solutions
 
Jwt the complete guide to json web tokens
remayssat
 
Identity and Access Management - RSA 2017 Security Foundations Seminar
Brian Campbell
 
Starwest 2008
Caleb Sima
 
Authorization Using JWTs
ForgeRock Identity Tech Talks
 
Spa Secure Coding Guide
Geoffrey Vandiest
 
2011 and still bruteforcing - OWASP Spain
Christian Martorella
 
JWT Authentication with AngularJS
robertjd
 
Roberto Bicchierai - Defending web applications from attacks
Pietro Polsinelli
 
Javascript Object Signing & Encryption
Aaron Zauner
 
Jwt with flask slide deck - alan swenson
Jeffrey Clark
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
CODE BLUE
 
Ad

More from Ivan Rosolen (17)

PDF
15 mandamentos de um bom programador
Ivan Rosolen
 
PDF
Utilizando Filas com PHP
Ivan Rosolen
 
PDF
Filas com php
Ivan Rosolen
 
PDF
Boas Práticas com PHP
Ivan Rosolen
 
PDF
Mercado de Tecnologia
Ivan Rosolen
 
PPTX
Deploy automatizado de Aplicações no Jelastic
Ivan Rosolen
 
PDF
Tecnologias e Inovação
Ivan Rosolen
 
PDF
Rest Beer v2
Ivan Rosolen
 
PPTX
Jelastic
Ivan Rosolen
 
PPTX
Aws video creator
Ivan Rosolen
 
PPTX
Cassandra 7 masters
Ivan Rosolen
 
PDF
Quando o planejamento da infraestrutura leva ao sucesso
Ivan Rosolen
 
PDF
Case: PHP como Base de Digital Asset Management – arizona.flow
Ivan Rosolen
 
PDF
Php e Cassandra
Ivan Rosolen
 
PDF
Criando APIs usando o micro-framework Respect
Ivan Rosolen
 
PDF
PHPT
Ivan Rosolen
 
KEY
CakePHP e o desenvolvimento rápido
Ivan Rosolen
 
15 mandamentos de um bom programador
Ivan Rosolen
 
Utilizando Filas com PHP
Ivan Rosolen
 
Filas com php
Ivan Rosolen
 
Boas Práticas com PHP
Ivan Rosolen
 
Mercado de Tecnologia
Ivan Rosolen
 
Deploy automatizado de Aplicações no Jelastic
Ivan Rosolen
 
Tecnologias e Inovação
Ivan Rosolen
 
Rest Beer v2
Ivan Rosolen
 
Jelastic
Ivan Rosolen
 
Aws video creator
Ivan Rosolen
 
Cassandra 7 masters
Ivan Rosolen
 
Quando o planejamento da infraestrutura leva ao sucesso
Ivan Rosolen
 
Case: PHP como Base de Digital Asset Management – arizona.flow
Ivan Rosolen
 
Php e Cassandra
Ivan Rosolen
 
Criando APIs usando o micro-framework Respect
Ivan Rosolen
 
CakePHP e o desenvolvimento rápido
Ivan Rosolen
 
Ad

Recently uploaded (20)

PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 

Autenticação com Json Web Token (JWT)