Skip to content

Flask application with UI and REST API endpoints to manage user registration and authentication through AWS Cognito. [DOCUMENTED]

Notifications You must be signed in to change notification settings

lbaiyat/cognito-flask-auth-demo

Repository files navigation

Cognito Flask Auth Demo


Overview:

This is a demo application created using Flask and Cognito to display a UI that manages user registration and authentication. There are rendered html pages and REST API endpoints that correspond to the registration, authentication, and authenticated user view.

About AWS Cognito:

AWS Cognito is a service that enables developers to add user sign-up, sign-in, and access control to their web and mobile applications quickly and securely. It supports user authentication, authorization, and user management, allowing integration with social identity providers and enterprise identity providers via SAML 2.0.

Instructions:

Getting the application up and running requires a few steps outlined below.

Setup virtual environment


python3 -m venv venv;
pip install -r requirements.txt;

Export AWS Access Key and Secret Key to environment variables


export AWS_ACCESS_KEY_ID="{ACCESS_KEY_ID_STRING}";
export AWS_SECRET_ACCESS_KEY="{AWS_SECRET_ACCESS_KEY_STRING}";

Create the Cognito User Pool with the Cognito Pool Manager Script

Note: The 'create' keyword after the script is needed. Creating this Data Stream will incur AWS charges


python3 cognito_pool_manager.py create;

Run the Flask App


python3 app.py;

Once the Flask app is running, you should be able to access the webpage

Pages:

Login Page:

Login Page

Registration Page

Registration Page

Logged In Page

Logged In Page

Cleanup:

Once you are done with using the Cognito User Pool, you should delete the instance to stop incurring further charges.

Delete the Cognito User Pool with the Cognito Pool Script

Note: The 'delete' keyword after the script is needed. The CloudFormation stack will be deleted as well as the Kinesis Stream defined by it.


python3 cognito_pool_manager.py delete;

About

Flask application with UI and REST API endpoints to manage user registration and authentication through AWS Cognito. [DOCUMENTED]

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published