An easy implementation of TOTP to be used in the AWS Lambda and DynamoDB.
It is built with Chalice and PyOTP.
1 - Set up your AWS Credentials
2 - Create a table in DynamoDB
3 - Configure the TABLE_NAME
constant in the chalicelib/config.py
file with the name of your table.
4 - Create a new virtualenv with Python 3.
5 - Inside of the virtualenv, install the requirements with pip install -r requirements.txt
6 - Execute the command chalice deploy
7 - Save the link returned by the chalice. It's the link to your application
To register a new user send a POST
request to the root path of your application with the value user
containing some kind of identification of your user, like an e-mail or user_id. The application will return a JSON in the following format:
{
"user_id": "[email protected]",
"qr_code": "",
"qr_code_url": ""
}
- user_id: The user id you have registred your user
- qr_code: The code used to create the QRcode image
- qr_code_url: The QRcode image that your user must read in his TOTP app to generate the Time Based One Time Password
The application will return an HTTP Conflict error in case the user is already registered.
Once the user is registered, you can send a GET
request passing in the params user
and code
user
is the user identification you registered your usercode
is the code generated by the TOTP application of your user
To run the test suite, please run the following command
$ pytest -vvx tests
Contributions are welcome!