Skip to main content

Two-layer RBAC (system + company) helpers for FastAPI / Flask / any Python backend — paired with the @snipe/auth-rbac TS sibling.

Project description

snipe-auth-rbac

Python sibling of @snipe/auth-rbac. Two-layer RBAC (system + per-company roles) for FastAPI / Flask / any Python backend.

See the top-level README for the full picture and the adoption guide for everyday usage.

Install

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

Three-line FastAPI integration

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snipe_auth_rbac-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snipe_auth_rbac-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file snipe_auth_rbac-0.1.0.tar.gz.

File metadata

  • Download URL: snipe_auth_rbac-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for snipe_auth_rbac-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e24c277cfe294fc79e9624418b6f3184c3aadc3ac9e660ff4a7cc8181412b6e6
MD5 1f46b67ace23ac104a5f260ee31981ec
BLAKE2b-256 392e25b9f0a83ef3de2e1d60a6938adc8d428a83a2661080492d16fc588000e4

See more details on using hashes here.

File details

Details for the file snipe_auth_rbac-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snipe_auth_rbac-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abebd74fe5bae74a9c1369e7a320d94c9f741f6d2dd6c778a7815895b2b5de85
MD5 46e486a6db18c1440e0c8ec0c3bf2c1c
BLAKE2b-256 2f33c733c9f873676a1d9b1e4286f4ecc05ad9b35ef97fedd969f5e2e3f87cf2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page