InterviewSolution
| 1. |
What is JWT? |
|
Answer» JWT (JSON Web Tokens) are tokens that are generated by a server upon user authentication in a web application and are then sent to the CLIENT (normally a browser). As a result, these tokens are sent on every HTTP request, allowing the server to verify or authenticate the user's identity. This method is used for authorizing transactions or requests between client and server. The use of JWT does not intend to hide data, but rather ensure its authenticity. JWTs are signed and encoded, INSTEAD of encrypted. A cryptographic algorithm is used to digitally sign JWTs in order to ensure that they cannot be altered after they are issued. INFORMATION contained in the token is signed by the server's private key in order to ensure integrity.
Three parts make up JSON Web Tokens, separated by a dot (.). The first two (the header and the PAYLOAD) contain Base64-URL encoded JSON, while the third is a cryptographic signature. For example: eyJhbGciOfefeiI1NiJ9.eyJuYW1lIjdgdfeENvZGVyIn0.5dlp7GmziL2dfecegse4mtaqv0_xX4oFUuTDh14KuFTake a look at each of the sections: eyJhbGciOfefeiI1NiJ9 #headereyJuYW1lIjdgdfeENvZGVyIn0 #payload5dlp7GmziL2dfecegse4mtaqv0_xX4oFUuTDh14KuF #signature |
|