Registry / auth-security / drf-access-policy

drf-access-policy

JSON →
library1.5.0pypypi✓ verified 81d ago

Declarative access policies/permissions modeled after AWS' IAM policies for Django REST Framework. Current version 1.5.0, with active development and periodic releases.

pip install drf-access-policy
INSTALL
IMPORT
SIG · DRF-ACCESS-POLICY
D
drf-access-policy
auth-securitypythonv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AccessPolicy
from rest_access_policy import AccessPolicy
from rest_framework_access_policy import AccessPolicy

Define an access policy as a dictionary on the view. The policy controls actions allowed for principals.

from rest_framework.views import APIView from rest_framework_access_policy import AccessPolicy class MyView(APIView): access_policy = { "statements": [ { "action": ["list"], "principal": "*", "effect": "allow", }, ] }
Debug
Known issues
breakingVersion 1.0.0 changed condition evaluation: 'condition' no longer supports multiple methods with boolean logic. Use 'condition_expression' instead.
fix
Replace 'condition' elements with 'condition_expression' and use Python-style boolean operators.
affects: >=1.0.0
gotchaImport path is 'rest_framework_access_policy', not 'drf_access_policy'. Many users mistakenly use the latter.
fix
Use 'from rest_framework_access_policy import AccessPolicy'.
affects: all
deprecatedPython 3.5 support dropped in version 1.5.0. Use Python 3.6+.
fix
Upgrade your Python environment to 3.6 or newer.
affects: >=1.5.0
Upgrade
Version history
1.5.0latest on PyPI · released Mar 2, 2023
Audit
Dependencies
djangorequiredRequired for Django REST Framework integration.
djangorestframeworkrequiredThe library extends DRF's permission classes.
Agent activity
14 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
drf-access-policy — pip install drf-access-policy · libregistry