Policy document evaluator plugin for Spakky auth
Project description
spakky-policy
spakky-policy loads YAML, TOML, and JSON policy documents into typed canonical
models and evaluates RBAC, PBAC, and ABAC-style authorization rules for
spakky-auth.
Installation
pip install spakky-policy
Usage
from spakky.auth import AuthContext, AuthSubject
from spakky.plugins.policy import PolicyDocumentEvaluator, PolicyEvaluationInput
from spakky.plugins.policy.loader import policy_document_from_mapping
document = policy_document_from_mapping(
{
"version": "2026-06",
"metadata": {"name": "article-policy"},
"roles": [{"ref": "role:editor", "permissions": ["permission:article-read"]}],
"policies": [
{
"ref": "policy:article-read",
"statements": [
{
"ref": "allow-editor-read",
"effect": "allow",
"roles": ["role:editor"],
"permissions": ["permission:article-read"],
"resources": ["article:1"],
"actions": ["article:read"],
}
],
}
],
}
)
auth_context = AuthContext(
subject=AuthSubject(id="user:alice"),
issuer="issuer:test",
roles=("role:editor",),
)
result = PolicyDocumentEvaluator(document).evaluate(
PolicyEvaluationInput(
auth_context=auth_context,
resource="article:1",
action="article:read",
policy="policy:article-read",
)
)
assert result.allowed is True
Policy Semantics
- Explicit deny statements take precedence over matching allow statements.
- No matching allow statement returns default deny evidence.
- Conditions support
all,any, andnotcomposition plusequals,not_equals,in,contains, andexistsatomic operators. - Resource, action, and tenant refs are canonical strings supplied by
AuthorizationRequest, decorator metadata,AuthContext, or resolver output. - Named policies are the OR/ANY user-facing surface; MCP/tool authorization, generic policy APIs, policy UI, and authorized data filtering are out of scope.
License
MIT License
Project details
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 spakky_policy-6.5.0.tar.gz.
File metadata
- Download URL: spakky_policy-6.5.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc2580c05edb478cc0a45a9822544d39f385308e1ab49ee0130ab23ee4e8ecc2
|
|
| MD5 |
50c52b88d98f5d92e6a620ddfecda4bd
|
|
| BLAKE2b-256 |
96a820f4ba7da60035fd37262ca25d78fd3978881e79bf822c8a3b6423feab19
|
Provenance
The following attestation bundles were made for spakky_policy-6.5.0.tar.gz:
Publisher:
publish-package.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_policy-6.5.0.tar.gz -
Subject digest:
fc2580c05edb478cc0a45a9822544d39f385308e1ab49ee0130ab23ee4e8ecc2 - Sigstore transparency entry: 1817356468
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@c5d3c1d8449d535f43fc14aaf7e9f2ebf1ec1b89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@c5d3c1d8449d535f43fc14aaf7e9f2ebf1ec1b89 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spakky_policy-6.5.0-py3-none-any.whl.
File metadata
- Download URL: spakky_policy-6.5.0-py3-none-any.whl
- Upload date:
- Size: 12.2 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 |
c805565d9f1d81f782f438774e39023b6960fabeae679af4a7a9ce13d5928fde
|
|
| MD5 |
2413fd743914069396a5d7e354eebe5e
|
|
| BLAKE2b-256 |
fbe53591428e1c0000823ddaa6b4352005948e3cffd9f7d5206ded95171c90fd
|
Provenance
The following attestation bundles were made for spakky_policy-6.5.0-py3-none-any.whl:
Publisher:
publish-package.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_policy-6.5.0-py3-none-any.whl -
Subject digest:
c805565d9f1d81f782f438774e39023b6960fabeae679af4a7a9ce13d5928fde - Sigstore transparency entry: 1817356657
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@c5d3c1d8449d535f43fc14aaf7e9f2ebf1ec1b89 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-package.yml@c5d3c1d8449d535f43fc14aaf7e9f2ebf1ec1b89 -
Trigger Event:
workflow_dispatch
-
Statement type: