PanDA Authorization Library
Project description
panda-authz
Reusable authorization library for PanDA WMS services built on top of PyCasbin.
panda-authz provides:
- A shared Casbin model
- Standard matcher functions
- File-based policy loading
- A simple
AuthorizationServiceAPI - Reusable authorization logic across multiple PanDA WMS components
Installation
pip install panda-authz
Quick Start
Create a policy file, more about the policy format in the documentation:
# policy.csv
p, atlas-adc-pandamon, user_contact, read, {}, {}, allow
p, atlas-adc-pandamon, task, update, {"tasktype": "prod"}, {"priority": [500, 999]}, allow
Create and use the authorization service:
from panda_authz.service import AuthorizationService
authz = AuthorizationService("policy.csv")
allowed = authz.enforce(
["atlas-adc-pandamon"],
{"type": "user_contact"},
"read",
{},
)
print(allowed) # True
more examples in the documentation.
Django Integration
# oauth/authz.py
from django.conf import settings
from panda_authz.service import AuthorizationService
authz = AuthorizationService(settings.AUTHZ_POLICY_FILE)
Then use it in views or service code:
from oauth.authz import authz
if not authz.enforce(
request.user_roles,
{"type": "user_contact"},
"read",
{},
):
raise PermissionDenied()
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 panda_authz-1.0.5.tar.gz.
File metadata
- Download URL: panda_authz-1.0.5.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
752a61eda010a7d1b598c833395fecb2280bdee2a9bde9c1c1c4b1ed136fad67
|
|
| MD5 |
1b0a9dbe61a715f2113e55098551ab7a
|
|
| BLAKE2b-256 |
7f307776cf718e4c54a6cd62b77d8e6fc05596ad77b60a25ec9aa6c5c9f59c61
|
Provenance
The following attestation bundles were made for panda_authz-1.0.5.tar.gz:
Publisher:
release.yml on PanDAWMS/panda-authz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
panda_authz-1.0.5.tar.gz -
Subject digest:
752a61eda010a7d1b598c833395fecb2280bdee2a9bde9c1c1c4b1ed136fad67 - Sigstore transparency entry: 1316964037
- Sigstore integration time:
-
Permalink:
PanDAWMS/panda-authz@78f49bf403bcbf5dfda07a966d00c19170c80167 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PanDAWMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@78f49bf403bcbf5dfda07a966d00c19170c80167 -
Trigger Event:
push
-
Statement type:
File details
Details for the file panda_authz-1.0.5-py3-none-any.whl.
File metadata
- Download URL: panda_authz-1.0.5-py3-none-any.whl
- Upload date:
- Size: 8.1 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 |
31ffd85136696e4a7723e5837f575594a13b22da60be9e56132782aee94dabff
|
|
| MD5 |
fb053a23ed05b7321a5edfbb7e680417
|
|
| BLAKE2b-256 |
97f6d09fb1e97b45ef5c0b23826f407a1e875a9e73c1b004150d95cfc8b98c4d
|
Provenance
The following attestation bundles were made for panda_authz-1.0.5-py3-none-any.whl:
Publisher:
release.yml on PanDAWMS/panda-authz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
panda_authz-1.0.5-py3-none-any.whl -
Subject digest:
31ffd85136696e4a7723e5837f575594a13b22da60be9e56132782aee94dabff - Sigstore transparency entry: 1316964045
- Sigstore integration time:
-
Permalink:
PanDAWMS/panda-authz@78f49bf403bcbf5dfda07a966d00c19170c80167 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PanDAWMS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@78f49bf403bcbf5dfda07a966d00c19170c80167 -
Trigger Event:
push
-
Statement type: