-
-
Save monkey-codes/a716920201c8569de5539f65dc1d54a6 to your computer and use it in GitHub Desktop.
JWT breakdown pseudo code
This file contains hidden or 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
| var header = { | |
| "alg": "RS256", | |
| "typ": "JWT" | |
| }; | |
| var payload = { | |
| "exp": 1480395277, //Reserved claim - Expiration time | |
| "user_name": "reader", //Public claim | |
| "authorities": [ //Public claim | |
| "ROLE_READER" | |
| ], | |
| "jti": "5acda3f8-4c85-4000-a01f-b92a3738197a", //Reserved claim - JWT ID | |
| "client_id": "web-app", // Public claim | |
| "scope": [ // Public claim | |
| "read" | |
| ] | |
| }; | |
| var encodedString = base64UrlEncode(header) + "." + base64UrlEncode(payload); | |
| var privateKey = 'secret private key...'; | |
| var signature = SHA256withRSA(encodedString, privateKey); | |
| var JWT = encodedString + "." + base64UrlEncode(signature); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment