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==
Screencast
Utilizando PHP será explicado como gerar de forma manual (sem uso de
qualquer biblioteca) um JSON Web Token, que pode ser utilizado para
compartilhar informações entre aplicações e autorizar o portador do
token a acessar dados protegidos.
https://www.youtube.com/watch?v=k3KfK0ZS_FY
Warning!
Code
PHP Experience 2016 - [Palestra] Json Web Token (JWT)
PHP Experience 2016 - [Palestra] Json Web Token (JWT)
Github
- Session
- JWT
- JOSE
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
https://joind.in/talk/05eb0

More Related Content

PDF
JSON Web Token
PDF
JSON Web Tokens
PDF
Autenticação com Json Web Token (JWT)
PPTX
Building Secure User Interfaces With JWTs (JSON Web Tokens)
PPTX
Token Based Authentication Systems with AngularJS & NodeJS
PDF
Modern API Security with JSON Web Tokens
PDF
Using JSON Web Tokens for REST Authentication
PPTX
Micro Web Service - Slim and JWT
JSON Web Token
JSON Web Tokens
Autenticação com Json Web Token (JWT)
Building Secure User Interfaces With JWTs (JSON Web Tokens)
Token Based Authentication Systems with AngularJS & NodeJS
Modern API Security with JSON Web Tokens
Using JSON Web Tokens for REST Authentication
Micro Web Service - Slim and JWT

What's hot (19)

PDF
Json web token
PDF
Json web token api authorization
PDF
What are JSON Web Tokens and Why Should I Care?
PDF
iMasters Intercon 2016 - Identity within Microservices
PPTX
Securing Single Page Applications with Token Based Authentication
PPTX
Token Based Authentication Systems
PPTX
Architecting Secure and Compliant Applications with MongoDB
PDF
Protecting Java Microservices: Best Practices and Strategies
PDF
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
PDF
Javascript Object Signing & Encryption
PDF
Applying Security Controls on REST APIs
PPTX
Ignite Talk: I AM a robot, how do I log in?
PPTX
Top 10 Web Hacks 2012
PPTX
W3 conf hill-html5-security-realities
PDF
I Don't Care About Security (And Neither Should You)
PDF
PHP Identity and Data Security
PPTX
Secure Payments Over Mixed Communication Media
PPTX
Java Session
PDF
Insecurity-In-Security version.1 (2010)
Json web token
Json web token api authorization
What are JSON Web Tokens and Why Should I Care?
iMasters Intercon 2016 - Identity within Microservices
Securing Single Page Applications with Token Based Authentication
Token Based Authentication Systems
Architecting Secure and Compliant Applications with MongoDB
Protecting Java Microservices: Best Practices and Strategies
OAuth 2.0 – A standard is coming of age by Uwe Friedrichsen
Javascript Object Signing & Encryption
Applying Security Controls on REST APIs
Ignite Talk: I AM a robot, how do I log in?
Top 10 Web Hacks 2012
W3 conf hill-html5-security-realities
I Don't Care About Security (And Neither Should You)
PHP Identity and Data Security
Secure Payments Over Mixed Communication Media
Java Session
Insecurity-In-Security version.1 (2010)
Ad

Viewers also liked (16)

PPT
Web 2.0 - From a Social to a Service Web
PDF
PHP Experience 2016 - [Palestra] Keynote: PHP-7
PDF
PHP Experience 2016 - [Workshop] Deploy escalável na Amazon AWS
PDF
PHP Experience 2016 - [Palestra] Melhorando a comunicação da API através de DSL
PDF
PHP Experience 2016 - [Palestra] Autenticação em APIs
PDF
Waw - Gas
PDF
PHP Experience 2016 - [Workshop] APIs bem desenhadas como base para integrações
PDF
Boas práticas de API Design
PPTX
PHP Experience 2016 - [Workshop] Agile: Test Driven Development
PDF
PHP Experience 2016 - [Palestra] Rumo à Certificação PHP
PDF
How to scale PHP applications
ODP
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
PDF
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
PDF
Stateless token-based authentication for pure front-end applications
PPSX
What I learnt: Elastic search & Kibana : introduction, installtion & configur...
PDF
Integrating React.js Into a PHP Application
Web 2.0 - From a Social to a Service Web
PHP Experience 2016 - [Palestra] Keynote: PHP-7
PHP Experience 2016 - [Workshop] Deploy escalável na Amazon AWS
PHP Experience 2016 - [Palestra] Melhorando a comunicação da API através de DSL
PHP Experience 2016 - [Palestra] Autenticação em APIs
Waw - Gas
PHP Experience 2016 - [Workshop] APIs bem desenhadas como base para integrações
Boas práticas de API Design
PHP Experience 2016 - [Workshop] Agile: Test Driven Development
PHP Experience 2016 - [Palestra] Rumo à Certificação PHP
How to scale PHP applications
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
PHP Experience 2016 - [Workshop] Elastic Search: Turbinando sua aplicação PHP
Stateless token-based authentication for pure front-end applications
What I learnt: Elastic search & Kibana : introduction, installtion & configur...
Integrating React.js Into a PHP Application
Ad

Similar to PHP Experience 2016 - [Palestra] Json Web Token (JWT) (20)

PDF
RoadSec 2017 - Trilha AppSec - APIs Authorization
PPTX
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
PDF
Securing Web Applications with Token Authentication
PPTX
Building Secure User Interfaces With JWTs
PDF
Jwt the complete guide to json web tokens
PPTX
Identity and Access Management - RSA 2017 Security Foundations Seminar
PPTX
Token Authentication for Java Applications
PDF
Authorization Using JWTs
PDF
JSON WEB TOKEN
PPTX
JWT Authentication with AngularJS
PPT
Web Attacks - Top threats - 2010
PPTX
OWASP Free Training - SF2014 - Keary and Manico
PDF
Jwt with flask slide deck - alan swenson
PPTX
Spa Secure Coding Guide
PDF
Introduction to JWT and How to integrate with Spring Security
PPTX
Roberto Bicchierai - Defending web applications from attacks
PDF
jwt.pdf
PDF
[4developers2016] - Security in the era of modern applications and services (...
PDF
Jwt Security
PPTX
Is your mobile app as secure as you think?
RoadSec 2017 - Trilha AppSec - APIs Authorization
Uniface Lectures Webinar - Application & Infrastructure Security - JSON Web T...
Securing Web Applications with Token Authentication
Building Secure User Interfaces With JWTs
Jwt the complete guide to json web tokens
Identity and Access Management - RSA 2017 Security Foundations Seminar
Token Authentication for Java Applications
Authorization Using JWTs
JSON WEB TOKEN
JWT Authentication with AngularJS
Web Attacks - Top threats - 2010
OWASP Free Training - SF2014 - Keary and Manico
Jwt with flask slide deck - alan swenson
Spa Secure Coding Guide
Introduction to JWT and How to integrate with Spring Security
Roberto Bicchierai - Defending web applications from attacks
jwt.pdf
[4developers2016] - Security in the era of modern applications and services (...
Jwt Security
Is your mobile app as secure as you think?

More from iMasters (20)

PPTX
O que você precisa saber para modelar bancos de dados NoSQL - Dani Monteiro
PDF
Postgres: wanted, beloved or dreaded? - Fabio Telles
PPTX
Por que minha query esta lenta? - Suellen Moraes
PPTX
Relato das trincheiras: o dia a dia de uma consultoria de banco de dados - Ig...
PDF
ORMs heróis ou vilões dentro da arquitetura de dados? - Otávio gonçalves
PPTX
SQL e NoSQL trabalhando juntos: uma comparação para obter o melhor de ambos -...
PDF
Arquitetando seus dados na prática para a LGPD - Alessandra Martins
PDF
O papel do DBA no mundo de ciência de dados e machine learning - Mauro Pichil...
PDF
Desenvolvimento Mobile Híbrido, Nativo ou Web: Quando usá-los - Juliana Chahoud
PDF
Use MDD e faça as máquinas trabalharem para você - Andreza Leite
PDF
Entendendo os porquês do seu servidor - Talita Bernardes
PDF
Backend performático além do "coloca mais máquina lá" - Diana Arnos
PPTX
Dicas para uma maior performance em APIs REST - Renato Groffe
PPTX
7 dicas de desempenho que equivalem por 21 - Danielle Monteiro
PDF
Quem se importa com acessibilidade Web? - Mauricio Maujor
PDF
Service Mesh com Istio e Kubernetes - Wellington Figueira da Silva
PDF
Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti
PDF
Elasticidade e engenharia de banco de dados para alta performance - Rubens G...
PDF
Construindo aplicações mais confiantes - Carolina Karklis
PDF
Monitoramento de Aplicações - Felipe Regalgo
O que você precisa saber para modelar bancos de dados NoSQL - Dani Monteiro
Postgres: wanted, beloved or dreaded? - Fabio Telles
Por que minha query esta lenta? - Suellen Moraes
Relato das trincheiras: o dia a dia de uma consultoria de banco de dados - Ig...
ORMs heróis ou vilões dentro da arquitetura de dados? - Otávio gonçalves
SQL e NoSQL trabalhando juntos: uma comparação para obter o melhor de ambos -...
Arquitetando seus dados na prática para a LGPD - Alessandra Martins
O papel do DBA no mundo de ciência de dados e machine learning - Mauro Pichil...
Desenvolvimento Mobile Híbrido, Nativo ou Web: Quando usá-los - Juliana Chahoud
Use MDD e faça as máquinas trabalharem para você - Andreza Leite
Entendendo os porquês do seu servidor - Talita Bernardes
Backend performático além do "coloca mais máquina lá" - Diana Arnos
Dicas para uma maior performance em APIs REST - Renato Groffe
7 dicas de desempenho que equivalem por 21 - Danielle Monteiro
Quem se importa com acessibilidade Web? - Mauricio Maujor
Service Mesh com Istio e Kubernetes - Wellington Figueira da Silva
Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti
Elasticidade e engenharia de banco de dados para alta performance - Rubens G...
Construindo aplicações mais confiantes - Carolina Karklis
Monitoramento de Aplicações - Felipe Regalgo

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Pre independence Education in Inndia.pdf
PPTX
Cell Types and Its function , kingdom of life
Pharmacology of Heart Failure /Pharmacotherapy of CHF
STATICS OF THE RIGID BODIES Hibbelers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Renaissance Architecture: A Journey from Faith to Humanism
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPH.pptx obstetrics and gynecology in nursing
Pre independence Education in Inndia.pdf
Cell Types and Its function , kingdom of life

PHP Experience 2016 - [Palestra] Json Web Token (JWT)