FastAPIUIAuth
Python module to add username and password authentication to specific FastAPI routes
Platform Supported
Deployments
Installation
pip install FastAPI-UI-Auth
Usage
import logging
import uiauth
from fastapi import FastAPI
from fastapi.routing import APIRoute
app = FastAPI()
@app.get("/public")
async def public_route():
return {"message": "This is a public route"}
async def private_route():
return {"message": "This is a private route"}
uiauth.protect(
# ------ MANDATORY ARGS ------
app=app,
routes=APIRoute(
path="/private",
endpoint=private_route
),
username="admin",
password="password123",
# ------ OPTIONAL ARGS ------
totp_token="JBSWSECUREDK3PXP",
session_timeout=3600,
fallback=uiauth.Fallback(button="GO BACK", path="/public"),
custom_logger=logging.getLogger("my_custom_logger")
)
FastAPI-UI-Authsupports bothAPIRouteandAPIWebSocketRouteroutes.
Refer samples directory for different use-cases.
Coding Standards
Docstring format: Google
Styling conventions: PEP 8 and isort
Release Notes
Requirement
python -m pip install gitverse
Usage
gitverse-release reverse -f release_notes.rst -t 'Release Notes'
Linting
Requirement
python -m pip install sphinx==5.1.1 pre-commit recommonmark
Usage
pre-commit run --all-files
Pypi Package
https://pypi.org/project/FastAPI-UI-Auth/
License & copyright
© Vignesh Rao
Licensed under the MIT License
Metadata
Release files for FastAPI-UI-Auth 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_ui_auth-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / fastapi_ui_auth-0.5.0-py3-none-any.whl
| Download URL | fastapi_ui_auth-0.5.0-py3-none-any.whl |
|---|---|
| Size | 24.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2502baf090b87d9a068a43cb87afa561b1025060f169254565eb906031d0131
|
|
BLAKE2b-256 checksum How to use checksums |
bec11c4b83e3e7c88295ef89b42665dd2cf7b06c25e388b171e67899b3eed10b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.0rc1
|