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, panda, user_contact, read, {}, {}, allow
p, panda, 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(
    ["panda"],
    "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_PATH)

Then use it in views or service code:

from oauth.authz import authz
if not authz.enforce(
    request.user_roles,
    "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-2.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-2.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panda_authz-2.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-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b4072dda766c9e5d686ce1b327ee55d7fd4e22245b4e7b4e37400b71d9014748
MD5 d31b8ef22375c156da4a710d6562414d
BLAKE2b-256 0b65e1e7b36c4edf268d2c6d67bbdcc25a8f88d3b742c0d257770718d3967341

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: panda_authz-2.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-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aaa47b9c58966cf01e817cca37292946f632e23652625c4986fb5ab03fee1b61
MD5 34c3f8cd82eed9752be4541d62ea3b06
BLAKE2b-256 05a8e1807a2effc085dc57e80ed035df77dc18999bba3989bf5b5da235dea16c

See more details on using hashes here.

Provenance

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