Highly configurable authentication and authorization package wrapping Keycloak
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
authflow-0.3.1.tar.gz
(53.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
authflow-0.3.1-py3-none-any.whl
(64.9 kB
view details)
File details
Details for the file authflow-0.3.1.tar.gz.
File metadata
- Download URL: authflow-0.3.1.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeac0e3043e3d3b1b4cf67b46e6dc9be7b279a40decf12e02e9f1c602b1b8d67
|
|
| MD5 |
ac2badb7f9aef90757ea60a401efaf33
|
|
| BLAKE2b-256 |
c21b32eb263d7a5a79d6e779b4b784b2d4606b7fc434d74829eaf4eae9414133
|
File details
Details for the file authflow-0.3.1-py3-none-any.whl.
File metadata
- Download URL: authflow-0.3.1-py3-none-any.whl
- Upload date:
- Size: 64.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12318b3d9b764dd442977aa190f764a4a9cd2ed6d1492c6aa87d6d6cde43132b
|
|
| MD5 |
55096a229f4d36ddeacc6fa5d8d6d949
|
|
| BLAKE2b-256 |
eae2b189e5a854c24642d46bbf47e1e12944ee6c1567a07e9a6a3ba9a921e5df
|