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-0.0.0.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-0.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file panda_authz-0.0.0.tar.gz.

File metadata

  • Download URL: panda_authz-0.0.0.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-0.0.0.tar.gz
Algorithm Hash digest
SHA256 1441c8ec682419ca419738d3c8aff82487667c727ff7f36b68f36a101babb4bc
MD5 722a42d50ad41af69279b8d8c008c503
BLAKE2b-256 cfec63d023d4cb0d83aef100ab3ab0f085a4a112e71acded9468a7d818c8f28b

See more details on using hashes here.

Provenance

The following attestation bundles were made for panda_authz-0.0.0.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-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: panda_authz-0.0.0-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-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be813f28cb17758d51ecd5e48609acf2ac7adb9383f5b0beef5ad07b10fa81d9
MD5 d6a8615c259a753139e58e663da4c57e
BLAKE2b-256 fff26cde46537294003aad4c1db3d6d789e97740ff9ee6c67c87cba2a98a76da

See more details on using hashes here.

Provenance

The following attestation bundles were made for panda_authz-0.0.0-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