Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JSON Web Token

JSON Web Token

An introduction to the what, why and how of JSON Web Tokens

Laura Eck

July 08, 2016
Tweet

Other Decks in Technology

Transcript

  1. JSON Web Token (JWT) • open standard (RFC 7519) •

    transmit information between parties as a JSON object • compact and self-contained • can be verified and trusted with a digital signature
  2. JSON Web Token (JWT) • open standard (RFC 7519) •

    transmit information between parties as a JSON object • compact and self-contained • can be verified and trusted with a digital signature
  3. JSON { "event" : { "title" : "Tokyo Rubyist Meetup",

    "date" : "2016-07-07", "location" : { "company" : "VOYAGE GROUP", "address" : "౦ژ౎ौ୩۠ਆઘொ8-16" } }
  4. JSON Web Token (JWT) • open standard (RFC 7519) •

    transmit information between parties as a JSON object • compact and self-contained • can be verified and trusted with a digital signature
  5. Compact & Self-contained Compact: Relatively small —> can be sent

    through an URL, POST parameter, or inside an HTTP header Self-contained: Carries necessary information within itself
  6. JSON Web Token (JWT) • open standard (RFC 7519) •

    transmit information between parties as a JSON object • compact and self-contained • can be verified and trusted via digital signature
  7. Verification • sign information with digital signature (JWS) • verify

    with secret signing key • can also be encrypted (JWE)
  8. Payload { "sub": "1234567890", "name": "John Doe", "admin": true }

    Base64 eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6I kpvaG4gRG9lIiwiYWRtaW4iOnRydWV9
  9. Some things to keep in mind… • Secure the secret

    signing key • Always verify the signature before trusting information from the token
  10. Some things to keep in mind… • Secure the secret

    signing key • Always verify the signature before trusting information from the token • Don't accept tokens with { "alg": "none" } in the header unless you have a very good reason
  11. Some things to keep in mind… • Secure the secret

    signing key • Always verify the signature before trusting information from the token • Don't accept tokens with { "alg": "none" } in the header unless you have a very good reason
  12. Some things to keep in mind… • Secure the secret

    signing key • Always verify the signature before trusting information from the token • Don't accept tokens with { "alg": "none" } in the header unless you have a very good reason • Make sure your library has no security holes
  13. Some things to keep in mind… • Secure the secret

    signing key • Always verify the signature before trusting information from the token • Don't accept tokens with { "alg": "none" } in the header unless you have a very good reason • Make sure your library has no security holes
  14. • Don't contain sensitive data in a JWT Signed, not

    encrypted If you need encryption, check out JWE Some things to keep in mind…
  15. • Don't contain sensitive data in a JWT Signed, not

    encrypted If you need encryption, check out JWE • Use exp claim to let the token expire, add jti claim if you're worried about replay attacks Some things to keep in mind…
  16. • Don't contain sensitive data in a JWT Signed, not

    encrypted If you need encryption, check out JWE • Use exp claim to let the token expire, add jti claim if you're worried about replay attacks • The token needs to be stored client side, so make sure that's secure too! Some things to keep in mind…