It is the implementation of flask server authentication using bearer token
- Clone the git repo
- docker build -t <> .
- docker run -p 5000:5000 <>
-
User Sign Up POST /user/signup
Body Parameters:
- email_id
- type: String
- example: "abc@def.com"
- name
- type: String
- password
- type: String
Response:
- email_id
- name
- user_id
- type: Uuid
- email_id
-
User Login POST /user/login
Request Header:
- Basic Authentication in Authorization Header
Response:
- access_token
-
Fetch User Profile GET /user/profile
Request Header:
- Bearer Token in Authorization Header
Response:
- email_id
- name
- user_id
- When User sign up then all the information is stored in the test.db:user table
- When User logs in using basic authentication then backend validates the user, creates a session, and stores the session_id and email_id mapping in test.db:session table
- When User tries to fetch its profile then user has to provide Bearer Token recieved from 2, backend validates the session corresponding to provided bearer token and returns back the User profile if all is good
SQLITE, a lightweight DB, is used for storing the User and session information
curl -X POST -H 'Content-Type: application/json' -d '{"email_id": "<email_id>", "name": "", "password": ""}' -k http://localhost:5000/user/signup
curl -X POST -k -u <email_id>: http://localhost:5000/user/login
curl -k -H 'Authorization: Bearer <bearer_token>' http://localhost:5000/user/profile