Skip to main content

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 fnmatch glob 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

Metadata

Release files for libcan 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libcan 0.1.1
File Size Uploaded Provenance Actions
libcan-0.1.1.tar.gz 25.2 MB Without provenance Details for libcan-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for libcan 0.1.1
File Interpreter ABI Platform Actions
libcan-0.1.1-py3-none-any.whl Python 3 none any Details for libcan-0.1.1-py3-none-any.whl

Total release size: 25.2 MB

Release files / libcan-0.1.1.tar.gz

Download URL libcan-0.1.1.tar.gz
Size 25.2 MB
Tags Source
SHA-256 checksum
How to use checksums
a1df7d6798df5b7bc752208745d738255d126e9ca3b3bfbb83a67d61de538702
BLAKE2b-256 checksum
How to use checksums
a3df741034d677f02c7b07551bb8f42b855065233916a4603a0a9811dd5e33d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / libcan-0.1.1-py3-none-any.whl

Download URL libcan-0.1.1-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
419bea79f6ee751df80bf87b3db8dddd8f206d48e9da749cdcc234228291c6c5
BLAKE2b-256 checksum
How to use checksums
8553ff280878029b225cfe1182c6569bf3a7e06078c579a71c6b7a7761b4a60b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for libcan 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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