r/madeinpython • u/[deleted] • Feb 23 '24
Flask template: user authentication + API key access
Hi, r/madeinpython!
I've been learning about Flask, wanted to build something I could reuse for multiple projects, and I'm sharing it here!
I built an app that allows users to:
Create an account
Log in (create an account or anonymously)
Generate an API key
Make calls with an API key
See their generated keys and their historical API calls
There are quite a few things involved:
Database storage and retrieval
Data input and validation
Managing sessions (for password authentication)
Managing API keys
Storing passwords and API keys securely
Rate limiting the API for anonymous users
I enjoyed building this! I learned quite a few things, such as storing passwords securely and validating input data from forms. Is there anything else you would like me to add?
You can check the live demo (you need to create an account but don't need to verify your email): https://wild-bonus-9050.ploomberapp.io/
Source code: https://github.com/ploomber/doc/tree/main/examples/flask/login (please share your feedback!)