JavaScript Web Tokens
JWT
JWT?
JSON Web Tokens are an open, industry standard RFC 7519 method for
representing claims securely between two parties.
The claims in a JWT are encoded as a JSON object that is used as the payload of
a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web
Encryption (JWE) structure, enabling the claims to be digitally signed or integrity
protected with a Message Authentication Code (MAC) and/or encrypted.
Browser Server Sequence Now
Browser Server Sequence Now
Technology has changed!
Why JWT?
Cookies don’t work well with CORS
Cookies require stateful servers
APIS should be stateless
JWT much more scalable
CDN serve all the assets of your app, server side is just the API.
A Better Approach
JWT doesn’t use sessions, has no
problems with mobile, it doesn’t need
CSRF and it works very well with
CORS too. If you don’t have a valid
token you can't do anything.
JWT handle auth across devices and
services without managing sessions
on the server.
JWT Sequence
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Ikpv
aG4gRG9lIiwiYWRtaW4iOnRydWV9.
TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFO
NFh7HgQ
What is a JWT?
<base64-encoded header>.
<base64-encoded claims>.
<base64-encoded signature>
FYI
You should not send any secret
information using JWT, rather send
information that is not secret but
needs to be verified.
For instance, sending a signed user
id to indicate the user that should
be logged in would work great!
Sending a user's password would
be super bad.
Payload is not encrypted!
DEMO!
Basic Demo
Links
http://www.rfc-editor.org/rfc/rfc7519.txt
http://jwt.io/
https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-
dotnet

Jwt