Skip to main content

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 AuthorizationService API
  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panda_authz-1.0.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panda_authz-1.0.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for panda_authz-1.0.5.tar.gz
Algorithm Hash digest
SHA256 752a61eda010a7d1b598c833395fecb2280bdee2a9bde9c1c1c4b1ed136fad67
MD5 1b0a9dbe61a715f2113e55098551ab7a
BLAKE2b-256 7f307776cf718e4c54a6cd62b77d8e6fc05596ad77b60a25ec9aa6c5c9f59c61

See more details on using hashes here.

Provenance

The following attestation bundles were made for panda_authz-1.0.5.tar.gz:

Publisher: release.yml on PanDAWMS/panda-authz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for panda_authz-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 31ffd85136696e4a7723e5837f575594a13b22da60be9e56132782aee94dabff
MD5 fb053a23ed05b7321a5edfbb7e680417
BLAKE2b-256 97f6d09fb1e97b45ef5c0b23826f407a1e875a9e73c1b004150d95cfc8b98c4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for panda_authz-1.0.5-py3-none-any.whl:

Publisher: release.yml on PanDAWMS/panda-authz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page