Created
March 18, 2016 07:44
-
-
Save abhirockzz/912a3d75bdb64c5d2111 to your computer and use it in GitHub Desktop.
Anatomy of a JSON Web Token (JWT)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//header | |
{ | |
"alg": "HS256", | |
"typ": "JWT" | |
} | |
//payload/claims | |
{ | |
"sub": "1234567890", | |
"name": "John Doe", | |
"admin": true | |
} | |
//the formula | |
encoded_part = base64Of(header) + "." base64Of(payload) | |
signature = signedUsingHS256WithSecret(encoded_part) //assume that algo is HS256 and secret key is 'secret' | |
JWT = encoded_part + "." + sigature | |
//the JWT ( notice the separator/period --> "." ) | |
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 //base-64 encoded header | |
.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9 //base-64 encoded payload | |
.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ //the signature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment