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

Autenticação com Json Web Token (JWT)

Autenticação com Json Web Token (JWT)

Vamos falar sobre como utilizar JWT para autenticação de sua API. O que é? Para que serve? Porque precisamos dele? Como utilizar?

Ivan Rosolen

January 29, 2016
Tweet

More Decks by Ivan Rosolen

Other Decks in Technology

Transcript

  1. 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
  2. - Data is stored in plain text on the server

    - Filesystem read/write requests - Distributed/clustered applications - Redis/Sticky sessions
  3. API

  4. - Stateless authentication (simplifies horizontal scaling) - Prevent (mitigate) Cross-Site

    Request Forgery (CSRF) attacks. - Security (https) - Authorization: Bearer
  5. - JWT - JWS - JWA - JWK - JWE

    JSON Object Signing and Encryption
  6. - 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)
  7. 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