Working with authentication and authorization in web space, one cannot escape JWT and its variant. This is my short-note on the format.
JWT looks something like this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Which is three base64-url encoded parts, separated by dot (go find the two dots in example above).
- Header
which decodes to
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
{ "alg": "HS256", "typ": "JWT" }
- Body
which decodes to
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ
{ "sub": "1234567890", "name": "John Doe", "iat": 1516239022 }
- Signature
which does not decode. This is the value of:
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), SecretKey )