Skip to main content

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 smpy new.

Install

pip install simple_module_permissions

What it provides

  • Role and Permission SQLModel tables, seeded from module-registered defaults.
  • RequiresPermission("...") FastAPI dependency that honours both role-based and direct user-level grants (the framework also exposes require_permission(...) from auth.deps).
  • Admin UI for assigning roles/permissions to users, reached through the users admin area at /users/admin; role and user editors live at /permissions/roles/{id}/edit and /permissions/users/{id}/edit.
  • register_permissions(self, registry) hook — every module declares its permission strings at boot via registry.add_group(...); the registry dedupes and persists them.

Usage

Declare permissions at module boot:

# modules/orders/orders/module.py
from simple_module_core.permissions import PermissionRegistry


class OrdersModule(ModuleBase):
    meta = ModuleMeta(name="orders")

    def register_permissions(self, registry: PermissionRegistry) -> None:
        registry.add_group("Orders", ["orders.read", "orders.write"])

Guard a route:

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

router = APIRouter()


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

Admin flow: navigate to /users/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.

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.32.tar.gz (18.4 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.32-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for simple_module_permissions-0.0.32.tar.gz
Algorithm Hash digest
SHA256 503c402450336e03e22bedf016beb6db8ac6416a51c18862863622fd8542daca
MD5 6930ebc4ed79faeaec811a6e08561ee3
BLAKE2b-256 9b6c810f23e7738dd5c257d1f3e81530f30ba14928c95d8357a6813616d34dba

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_permissions-0.0.32.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.32-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_permissions-0.0.32-py3-none-any.whl
Algorithm Hash digest
SHA256 2c129ea4d6e0a49c3fc2d67386cf6f31ee3fce29ddb32a6bcadb26e550478297
MD5 88579c4f7d766ef2712ae928f8ffd35e
BLAKE2b-256 6ec62865fd49753757a316e47d5248aef278e37fe665a503ebbdc9eaf1b9b09a

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_permissions-0.0.32-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.

Release history Release notifications | RSS feed

0.0.33

2 files

This release

0.0.32 This release

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page