A demo webapp for token management which can be deployed using aws lambda functions.
- AWS account(Free Tier is available)
- RedisLabs Cloud database(Free tier available)
- AWS CLI installed
-
Get or create new
AWS Access Key ID
andAWS Secret Access Key
from Profile --> My Security Credentials from AWS Website. -
Run
aws configure
and add these details along withDefault region name
(ex:us-east-2
)$ aws configure AWS Access Key ID [None]:Your AWS Access Key ID AWS Secret Access Key [None]:Your AWS Secret Access Key Default region name [None]: Default region name Default output format [None]: $
-
Clone the repository to a folder
git clone
-
cd
into folder and create virtual environment and activate.python3 -m venv env . env/bin/activate
-
Install all required modules
pip3 install -r requirements.txt
-
Get RedisLab Cloud database credentials (host:port and password)
-
Update the details of database in src/constants.py file.
-
To test and run server locally run
chalice local
-
If it works fine then deploy on AWS lambda using
chalice deploy
-
{{url}}/auth
home route for testing-
GET Request
-
Include
Authorization : token
in headers -
Reply:
{ "result": "Hello *username", "status": "SUCCESS", "status_code": 1000 }
-
-
{{url}}/auth/signin
Signin route-
POST Request
-
Body:
{ "username" : "username", "password" : "password" }
-
Reply (includes token valid for 1 minute):
{ "result": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6IlNoYWdyaSIsInNhbHQiOiIwOTNlZGNlMTg3OTQzYmU1MDllZWQzZmQ3MGE0ODBhMjYwNWY4OTAxZjRiYWEwNzYzYjU0OTlmMzA2NmYzYmM0OTcwZTBjMTllMjU2YTI5ODY0NGE1ZGEwYjcyNTA5MDlhYjljNDYzYzE1OTFiNmQxNmNmNGY5NDAyOTJlYTAwYiIsImV4cCI6MTYxOTYwNzI0OX0.R_U90dOTSOLgHjVHGNqoPTir1w-E1coY9jDNr5fxo20", "status": "SUCCESS", "status_code": 1000 }
-
-
{{url}}/auth/signup
Signup new user-
POST Request
-
Body:
{ "username" : "username", "password" : "password" }
-
Reply:
{ "result": "", "status": "SUCCESS", "status_code": 1000 }
-
-
{{url}}/auth/password
Change password-
POST Request
-
Include
Authorization : token
in headers -
Body:
{ "password" : "new password" }
-
Reply:
{ "result": "", "status": "SUCCESS", "status_code": 1000 }
-