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.1.1.tar.gz
(39.2 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.1.1-py3-none-any.whl
(47.5 kB
view details)
File details
Details for the file authflow-0.1.1.tar.gz.
File metadata
- Download URL: authflow-0.1.1.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90bb2f38e4a33452659ec7e07d117865197bfde8db416eb5868381fc6a63d3c2
|
|
| MD5 |
d53125e0e6988f3a4564d85399bd4124
|
|
| BLAKE2b-256 |
fc470e5949c1fc5c6335de25f1ace1954982b1c93f96c5fc98ac83a5b4e5f8a5
|
File details
Details for the file authflow-0.1.1-py3-none-any.whl.
File metadata
- Download URL: authflow-0.1.1-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8225fb45bea81cf3a9a8adb93eb4f30bdf19639e407cbea05dd89294e81e08eb
|
|
| MD5 |
d5320bf44cbe5589debd9b95c847e6bf
|
|
| BLAKE2b-256 |
6bb78b218a3af7914c7d4eaa5ec062dd1f9d078cc708933c650b9d3e53343cd7
|