-
Notifications
You must be signed in to change notification settings - Fork 1
Authentication Explained
Ash Mishra edited this page Nov 27, 2017
·
2 revisions
This document explains the current User authentication and authorization system.
Authentication is the act of logging a user in.
Authorization is the act of verifying the access rights of a user to interact with a resource.
- In the current model, when the user wants to log in via a client (the browser), it enters its
usernameandpasswordand clicks log in. - An send action, the client makes a
POSTrequest to/api/authenticateroute with the username and the password as the payload. - The server receives this payload, and first sees if the username exists in the DB and the password matches the hashed password stored in the DB.
- If it does, the server creates an authentication token (
JWT) using asecret keythat only the server knows. - Then the server returns this
JWTtoken with a status code200 successto the client. - After which, for each subsequent request that is restricted to a registered user, the client will need to send that JWT in its payload to the server.
- The server decrypts the JWT, and if valid, proceeds with the request, else cancels it.
Below is a high level diagram of the entire process:
