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 smpy new.
Install
pip install simple_module_permissions
What it provides
RoleandPermissionSQLModel tables, seeded from module-registered defaults.RequiresPermission("...")FastAPI dependency that honours both role-based and direct user-level grants (the framework also exposesrequire_permission(...)fromauth.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}/editand/permissions/users/{id}/edit. register_permissions(self, registry)hook — every module declares its permission strings at boot viaregistry.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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_module_permissions-0.0.24.tar.gz.
File metadata
- Download URL: simple_module_permissions-0.0.24.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74d4caa3375bce1be68a8db2018abc0664900eaa751cd6fdc43a6fc0ddb5f798
|
|
| MD5 |
c8d187efa3751174b7001e826b17003f
|
|
| BLAKE2b-256 |
cb6c2688c9d9cb5903b037cee0deac1e1dc126df6b6e8a7084dc0fa2579ba07d
|
Provenance
The following attestation bundles were made for simple_module_permissions-0.0.24.tar.gz:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_permissions-0.0.24.tar.gz -
Subject digest:
74d4caa3375bce1be68a8db2018abc0664900eaa751cd6fdc43a6fc0ddb5f798 - Sigstore transparency entry: 2026220590
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@35bb8df75943c017d7a7d581859027157488f1d9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@35bb8df75943c017d7a7d581859027157488f1d9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_permissions-0.0.24-py3-none-any.whl.
File metadata
- Download URL: simple_module_permissions-0.0.24-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dc58fe6bce4581108eda223f631a089f515e282e2f0e91c31600371e3646a61
|
|
| MD5 |
9bf5088d5a6a48da788f83a5cd0def1b
|
|
| BLAKE2b-256 |
f6bcbb1cc0e69ac9bf4861f8ddcb44edd7c01b6ccc45fa7aae436fda60b83655
|
Provenance
The following attestation bundles were made for simple_module_permissions-0.0.24-py3-none-any.whl:
Publisher:
release.yml on antosubash/simple_module_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_permissions-0.0.24-py3-none-any.whl -
Subject digest:
1dc58fe6bce4581108eda223f631a089f515e282e2f0e91c31600371e3646a61 - Sigstore transparency entry: 2026220651
- Sigstore integration time:
-
Permalink:
antosubash/simple_module_python@35bb8df75943c017d7a7d581859027157488f1d9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@35bb8df75943c017d7a7d581859027157488f1d9 -
Trigger Event:
workflow_dispatch
-
Statement type: