Pythonic Role-Based Access Control with libcan-compatible state serialisation
Project description
libcan-python — Pythonic Role‑Based Access Control
A clean, thread‑safe RBAC engine that is fully compatible with the C libcan library at the serialisation level.
Features
- Add users, assign / revoke roles
- Allow and deny rules with
fnmatchglob patterns (*,?,[seq]) - Deny‑takes‑precedence semantics
- Thread‑safety built‑in
- Lazy loading from storage; automatic
commit()/push() - libcan‑identical state format – you can exchange state blobs between C and Python
- No external dependencies
Installation
pip install libcan
uv add libcan
uv pip install libcan
Quick start
from libcan import AccessControl, MemoryStorage
ac = AccessControl(MemoryStorage())
ac.add_user("alice")
ac.add_role("alice", "admin")
ac.allow("admin", "read:*", "*.txt")
ac.deny("admin", "read:secret", "*.txt")
if ac.allowed("alice", "read:file", "doc.txt"):
print("Access granted")
ac.commit() # persist
ac.close()
Storage backends
Implement the libcan.Storage abstract class to connect any database or file system.
License
MIT
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
libcan-0.1.1.tar.gz
(25.2 MB
view details)
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 libcan-0.1.1.tar.gz.
File metadata
- Download URL: libcan-0.1.1.tar.gz
- Upload date:
- Size: 25.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1df7d6798df5b7bc752208745d738255d126e9ca3b3bfbb83a67d61de538702
|
|
| MD5 |
7b7960ec861cd1ebca3f3f1601e7ce90
|
|
| BLAKE2b-256 |
a3df741034d677f02c7b07551bb8f42b855065233916a4603a0a9811dd5e33d4
|
File details
Details for the file libcan-0.1.1-py3-none-any.whl.
File metadata
- Download URL: libcan-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
419bea79f6ee751df80bf87b3db8dddd8f206d48e9da749cdcc234228291c6c5
|
|
| MD5 |
f02366a80bd30d0ec4452062282b4a1f
|
|
| BLAKE2b-256 |
8553ff280878029b225cfe1182c6569bf3a7e06078c579a71c6b7a7761b4a60b
|