Metadata-Version: 2.4
Name: snipe-auth-rbac
Version: 0.1.0
Summary: Two-layer RBAC (system + company) helpers for FastAPI / Flask / any Python backend — paired with the @snipe/auth-rbac TS sibling.
Project-URL: Homepage, https://github.com/snipe-solutions/auth-rbac
Project-URL: Issues, https://github.com/snipe-solutions/auth-rbac/issues
Author: Snipe Solutions
License: MIT
Keywords: auth,fastapi,permissions,rbac,supabase
Classifier: Framework :: FastAPI
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.110; extra == 'fastapi'
Requires-Dist: starlette>=0.37; extra == 'fastapi'
Provides-Extra: supabase
Requires-Dist: supabase>=2.0; extra == 'supabase'
Description-Content-Type: text/markdown

# snipe-auth-rbac

Python sibling of [`@snipe/auth-rbac`](https://github.com/snipe-solutions/auth-rbac).
Two-layer RBAC (system + per-company roles) for FastAPI / Flask /
any Python backend.

See the [top-level README](https://github.com/snipe-solutions/auth-rbac#readme)
for the full picture and the [adoption guide](https://github.com/snipe-solutions/auth-rbac/blob/main/CONTRIBUTING.md)
for everyday usage.

## Install

```bash
pip install "snipe-auth-rbac[fastapi]"
```

## Three-line FastAPI integration

```python
from auth_rbac import PermissionsService, ResourceDescriptor
from auth_rbac.deps import (
    configure_auth_rbac,
    require_permission,
    active_company_middleware,
)

service = PermissionsService(supabase=supabase, resources=RESOURCES)
service.sync_resources()      # auto-sync the registry on every boot
configure_auth_rbac(service=service, user_id_resolver=resolve_user_id)
app.middleware("http")(active_company_middleware)

@app.get("/payments")
async def list_payments(_=Depends(require_permission("payments", "read"))):
    ...
```

The Supabase migration that defines the `auth_rbac_*` tables ships
under `sql/` in the parent repo — apply it once before the first
boot.

## License

MIT.
