An Authentication API that currently runs with FastAPI, verifies a provided UserCredential with a MySQL DB, and returns an appropriate response.
To do next:
- Include a monitoring dashboard for responses from API
- To handle virtual environment, consider:
- containerization (Docker),
- App deployment (Heroku),
- Container orchestration (Kubernetes),
- venv activation scripts
- package managers (pipenv / poetry)
To activate virtual environment:
source myenv/bin/activate
To download all dependencies:
pip3 install -r requirements.txt
To run FASTAPI:
uvicorn main:app --reload
To update list of dependencies:
pip3 freeze > requirements.txt
- API: FastAPI Python
- DB: FreeDB (1 DB, 50MB, Limited Queries1)
- Monitoring: Grafana (TODO)
- A username, where first 2 characters indicate the user's country (e.g. SGuser1, USuser2) (min. length = 3)
- A password (min. length = 1)
- First check if username and password provided meet minimum length requirements
- Parse the country code out of the username and check if the country code is valid
- Verify credentials against DB/file: check by username match, followed by hashed password match
- Return an appropriate message or error, depending on where in the authentication the input fails
- First run uvicorn main:app --reload
- Go to localhost:8000/docs to send POST requests
- Usernames must be at least 3 characters long (2 for the country code, 1 for the name)
- Passwords are at least 1 character long (made with extensibility in mind)
- Passwords can include special characters like ! and numbers
- pycountry's library contains a reliable source of alpha-2 country codes, which is used for authentication
- User may input capital letters for country code, API is modified to still work
- Country code in database is always lowercase
Tested manually.
- Valid username and password
- Non-matched username, valid password
- Valid username, invalid password
- Invalid country code
- Username too short, password too short
Footnotes
-
MAX QUERIES PER HOUR 800, MAX UPDATES PER HOUR 800, MAX_CONNECTIONS_PER_HOUR 800, MAX Connections 800 โฉ