[Awesome Go, Iris] Iris enable JSON Web Tokens (JWT) middleware to authenticate MCV resources
Iris JSON Web Tokens (JWT) Middleware
JSON Web Token (JWT) is an open standard (RFC 7519 - https://tools.ietf.org/html/rfc7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA.
When should you use JSON Web Tokens?
Here are some scenarios where JSON Web Tokens are useful:
-
Authorization: This is the most common scenario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains.
-
Information Exchange: JSON Web Tokens are a good way of securely transmitting information between parties. Because JWTs can be signed—for example, using public/private key pairs—you can be sure the senders are who they say they are. Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn’t been tampered with.
Read more about JWT at: https://jwt.io/introduction/
Using JWT with Iris
The Iris JWT middleware was designed with security, performance and simplicity in mind, it protects your tokens from critical vulnerabilities that you may find in other libraries. It is based on kataras/jwt
package.
1 | package main |
Learn about refresh tokens, blocklist and more at: _examples/auth/jwt - https://github.com/kataras/iris/tree/master/_examples/auth/jwt.
References
[1] JSON Web Tokens - https://www.iris-go.com/docs/#/?id=json-web-tokens
[3] JSON Web Tokens - Iris - https://docs.iris-go.com/iris/security/jwt