SAPL Policy Enforcement Point (PEP) core library for Python
Project description
sapl-base
Core SAPL Policy Enforcement Point (PEP) library for Python. Provides the async PDP client, constraint enforcement engine, and enforcement primitives used by the framework integrations (sapl-flask, sapl-django, sapl-fastapi).
How It Works
Your application sends authorization subscriptions to the Policy Decision Point (PDP) and enforces the decision. The PDP evaluates SAPL policies and returns permit/deny decisions with optional obligations, advice, and resource transformations.
from sapl_base.pdp_client import PdpClient, PdpConfig
from sapl_base.types import AuthorizationSubscription
client = PdpClient(PdpConfig(base_url="https://localhost:8443"))
decision = await client.decide_once(AuthorizationSubscription(
subject={"user": "alice", "roles": ["DOCTOR"]},
action="read",
resource="patient-record",
))
print(decision.decision) # PERMIT, DENY, INDETERMINATE, or NOT_APPLICABLE
policy "permit doctors to read patient data"
permit
action == "read"
where
"DOCTOR" in subject.roles;
For streaming decisions that update as policies change:
async for decision in client.decide(subscription):
print(decision.decision)
What You Get
- Async HTTP client for all PDP REST endpoints (
decide-once,decide,multi-decide-once,multi-decide,multi-decide-all-once,multi-decide-all) - Streaming SSE subscriptions with automatic reconnect and exponential backoff
- Constraint enforcement engine with seven handler types (runnable, consumer, mapping, filter predicate, error handler, error mapping, method invocation)
- Built-in content filtering via
filterJsonContent(blacken, delete, replace) - Pre-enforce and post-enforce primitives for request/response authorization
- Three streaming enforcement strategies: enforce-till-denied, enforce-drop-while-denied, enforce-recoverable-if-denied
- Bearer token and HTTP basic auth support; HTTPS by default
Most applications should use a framework integration instead of this package directly.
Getting Started
pip install sapl-base
For the PEP implementation specification and constraint handler reference, see the PEP documentation.
Links
License
Apache-2.0
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 sapl_base-4.0.1.tar.gz.
File metadata
- Download URL: sapl_base-4.0.1.tar.gz
- Upload date:
- Size: 51.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4623dd0bb0ed19f16d20f2c10e4006077766f23d019ae13a25fcb34227363d6d
|
|
| MD5 |
6884ce81c5b4dbd0144dafdc5e01506b
|
|
| BLAKE2b-256 |
2d11a43d33778d73709f8f9916ff1604bc8e8c869166b0c634d2787bec71a014
|
File details
Details for the file sapl_base-4.0.1-py3-none-any.whl.
File metadata
- Download URL: sapl_base-4.0.1-py3-none-any.whl
- Upload date:
- Size: 31.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57d4e59bcd29bebd1aaf880f888c5e1b9ad5345dd3694cde7a24cd4669baea44
|
|
| MD5 |
acf5e196865a013fb621faa18f857d59
|
|
| BLAKE2b-256 |
c70703b6db51e3caaa3def51540a8c238fd0d4324a372915ab005702c8138249
|