A comprehensive FastAPI library for Authentication and NIST-style Role-Based Access Control (RBAC).
The documentation has been significantly improved and split into easy-to-digest resources:
- Documentation Index - Start here for the full overview.
- 🚀 Getting Started - Installation and basic usage.
- ⚙️ Configuration - Environment variables and setup.
- 🛡️ NIST RBAC Model - Learn about roles, hierarchies, and permissions.
- 🖥️ Admin Dashboard - Guide to the visual administration panel.
- 💻 Frontend Integration - Vanilla JS & React guides.
Check out the examples/ directory for practical implementations:
basic_app.py: Standard implementation.multi_tenancy.py: [NEW] Scoping users and roles to tenants.advanced_extension.py: [NEW] Custom User models, Hooks, and Email services.testing_example.py: [NEW] How to test your protected routes.
from fastapi import FastAPI
from fastapi_oauth_rbac import FastAPIOAuthRBAC
app = FastAPI()
# Initialize with default settings or your own Settings object
auth = FastAPIOAuthRBAC(app)
# Explicitly include the routes you want
auth.include_auth_router()
auth.include_dashboard()# For PostgreSQL support
pip install "fastapi-oauth-rbac[postgres]"
# For SQLite support (async)
pip install "fastapi-oauth-rbac[sqlite]"- Asynchronous: Full support for
aiosqlite,asyncpg, etc. - NIST RBAC: Advanced Role-Based Access Control with hierarchy.
- Full Auth Flow: Login, Signup, OAuth (Google), and Global Logout.
- Premium Dashboard: Manage users and roles through a beautiful glassmorphism UI.
MIT