Skip to main content

RBAC primitives — roles, permissions, @require_permission decorator, admin UI for simple_module

Project description

simple_module_permissions

Role-based access control (RBAC) for simple_module apps. Users get roles, roles carry permissions, and route handlers declare required permissions at the decorator or dependency layer.

Pre-wired into any app scaffolded with simple-module new.

Install

pip install simple_module_permissions

What it provides

  • Role and Permission SQLModel tables, seeded from module-registered defaults.
  • @require_permission("orders.read") route decorator and HasPermission("...") dependency.
  • Admin UI at /permissions/admin for assigning roles to users.
  • register_permissions() hook — every module declares its permission strings at boot, the registry dedupes and persists them.

Usage

Declare permissions at module boot:

# modules/orders/orders/module.py
class OrdersModule(ModuleBase):
    meta = ModuleMeta(name="orders")

    def register_permissions(self):
        return ["orders.read", "orders.write"]

Guard a route:

from fastapi import APIRouter, Depends
from permissions.deps import HasPermission   # type: ignore[import-not-found]

router = APIRouter()


@router.get("/orders", dependencies=[Depends(HasPermission("orders.read"))])
async def list_orders(): ...

Admin flow: navigate to /permissions/admin, create a role, assign permissions, assign the role to users.

Depends on

  • simple_module_core, simple_module_db, simple_module_hosting, simple_module_users

License

MIT — see LICENSE.

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

simple_module_permissions-0.0.14.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

simple_module_permissions-0.0.14-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_permissions-0.0.14.tar.gz.

File metadata

File hashes

Hashes for simple_module_permissions-0.0.14.tar.gz
Algorithm Hash digest
SHA256 ff5f22bd0ad3cb8b63c2562f0a40f1eee756209d86b25bfb08f62e8892f12be1
MD5 75efd1ce7c738d215351e5661ca89397
BLAKE2b-256 6c9d56106294b0357ee9355e21554a96f8700a829e9f61fa2db02f7e991a60a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_permissions-0.0.14.tar.gz:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_permissions-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_permissions-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 5de3f6713bb113a6075df0131f25d013eae68bac96380f60a06fa02df9694bb2
MD5 144c4316b64e79e800970e6060a23bab
BLAKE2b-256 2f83131e94fd0ca9ab42b4e8a26b30008889b98e1093d9e670d6a724c5a7f7f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_permissions-0.0.14-py3-none-any.whl:

Publisher: release.yml on antosubash/simple_module_python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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