authflow - Backend Package
Python/FastAPI backend for authflow-stack.
Installation
pip install authflow
Quick Start
from fastapi import FastAPI, Depends
from authflow import AuthFlow, setup_auth
from authflow.dependencies import get_current_user, require_permission
app = FastAPI()
# Initialize from config file
auth = AuthFlow.from_config("authflow.config.yaml")
setup_auth(app, auth, prefix="/api/v1/auth")
# Protected route
@app.get("/api/data")
async def get_data(user = Depends(get_current_user)):
return {"message": f"Hello {user.username}"}
# Permission-protected route
@app.post("/api/contracts")
@require_permission("contracts:write")
async def create_contract(user = Depends(get_current_user)):
return {"status": "created"}
Configuration
Create authflow.config.yaml:
provider:
type: keycloak
keycloak:
url: https://keycloak.example.com
realm: my-realm
client_id: authflow-client
client_secret: ${KEYCLOAK_SECRET}
features:
organizations: true
teams: true
email_verification: true
rbac:
model: role-based
scopes: [global, organization, team]
Development
pip install -e ".[dev]"
pytest
Metadata
Release files for authflow 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| authflow-0.4.0.tar.gz | 59.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| authflow-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 131.3 kB
Release files / authflow-0.4.0.tar.gz
| Download URL | authflow-0.4.0.tar.gz |
|---|---|
| Size | 59.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
456926453af0f07bd42579499ba0f066ad401023d60f24caa1ddb76e0b510be2
|
|
BLAKE2b-256 checksum How to use checksums |
5ee09d3f97abc13f7248d4027306fda32f073f08b4a3e2139426b6563cbaae28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / authflow-0.4.0-py3-none-any.whl
| Download URL | authflow-0.4.0-py3-none-any.whl |
|---|---|
| Size | 71.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9a53afb17f646231dc56906742cbea917c28d6d1e71884265b5f6844b7898a5
|
|
BLAKE2b-256 checksum How to use checksums |
959aa88d754f26148161b9d5c25b70d701329d7eb6a421e057942d456e8f4b19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|