Permguard Python SDK (Authorization Check) - https://www.permguard.com
Project description
Permguard Python SDK
The Permguard Python SDK provides a simple and flexible client to perform authorization checks against a Permguard Policy Decision Point (PDP) service using gRPC. Plase refer to the Permguard Documentation for more information.
Prerequisites
- Python 3.8, 3.9, 3.10, 3.11 (supported versions)
This package is compatible with the following Python versions:
Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11
Make sure you have one of these versions installed before proceeding.
Installation
Run the following command to install the SDK:
pip install permguard
Usage Example
Below is a sample Python code demonstrating how to create a Permguard client, build an authorization request using a builder pattern, and process the authorization response:
az_client = AZClient(with_endpoint("localhost", 9094))
principal = PrincipalBuilder("amy.smith@acmecorp.com").build()
entities = [
{
"uid": {"type": "MagicFarmacia::Platform::BranchInfo", "id": "subscription"},
"attrs": {"active": True},
"parents": [],
}
]
req = (
AZAtomicRequestBuilder(
895741663247,
"809257ed202e40cab7e958218eecad20",
"platform-creator",
"MagicFarmacia::Platform::Subscription",
"MagicFarmacia::Platform::Action::create",
)
.with_request_id("1234")
.with_principal(principal)
.with_entities_items("cedar", entities)
.with_subject_role_actor_type()
.with_subject_source("keycloack")
.with_subject_property("isSuperUser", True)
.with_resource_id("e3a786fd07e24bfa95ba4341d3695ae8")
.with_resource_property("isEnabled", True)
.with_action_property("isEnabled", True)
.with_context_property("time", "2025-01-23T16:17:46+00:00")
.with_context_property("isSubscriptionActive", True)
.build()
)
ok, response = az_client.check(req)
if ok:
print("✅ authorization permitted")
else:
print("❌ authorization denied")
if response and response.context:
if response.context.reason_admin:
print(f"-> reason admin: {response.context.reason_admin.message}")
if response.context.reason_user:
print(f"-> reason user: {response.context.reason_user.message}")
for eval in response.evaluations:
if eval.context and eval.context.reason_user:
print(f"-> reason admin: {eval.context.reason_admin.message}")
print(f"-> reason user: {eval.context.reason_user.message}")
if response and response.evaluations:
for eval in response.evaluations:
if eval.context:
if eval.context.reason_admin:
print(f"-> evaluation requestid {eval.request_id}: reason admin: {eval.context.reason_admin.message}")
if eval.context.reason_user:
print(f"-> evaluation requestid {eval.request_id}: reason user: {eval.context.reason_user.message}")
Created by Nitro Agility.
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 permguard-0.0.10.tar.gz.
File metadata
- Download URL: permguard-0.0.10.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8fb4841c50e4c8eae6731f70050b418ee380fb65083fbdb48911cbfcae747fe
|
|
| MD5 |
1d9e1b0d4ff4041f73896947880f05f1
|
|
| BLAKE2b-256 |
0623a83c6649dcd8244a71aa9a8dbb07fbecb1c8080cdfd1ed5b4b25b84c3287
|
Provenance
The following attestation bundles were made for permguard-0.0.10.tar.gz:
Publisher:
permguard-python-ci.yml on permguard/permguard-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
permguard-0.0.10.tar.gz -
Subject digest:
e8fb4841c50e4c8eae6731f70050b418ee380fb65083fbdb48911cbfcae747fe - Sigstore transparency entry: 179237439
- Sigstore integration time:
-
Permalink:
permguard/permguard-python@a7c62b15e9115ea8d28e3c09a4ad6ab56245b404 -
Branch / Tag:
refs/tags/v0.0.10 - Owner: https://github.com/permguard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
permguard-python-ci.yml@a7c62b15e9115ea8d28e3c09a4ad6ab56245b404 -
Trigger Event:
push
-
Statement type:
File details
Details for the file permguard-0.0.10-py3-none-any.whl.
File metadata
- Download URL: permguard-0.0.10-py3-none-any.whl
- Upload date:
- Size: 24.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac112767306cfee66ff423f5f17b301515d0006403f3c2045a6739a0d4707dd8
|
|
| MD5 |
695d7f72994feaf77a5a202e17b30d18
|
|
| BLAKE2b-256 |
cb229e43b5939861e941bc34cccf8ab80cdc73f96d7cb6074fa6a9bf8baa9fe9
|
Provenance
The following attestation bundles were made for permguard-0.0.10-py3-none-any.whl:
Publisher:
permguard-python-ci.yml on permguard/permguard-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
permguard-0.0.10-py3-none-any.whl -
Subject digest:
ac112767306cfee66ff423f5f17b301515d0006403f3c2045a6739a0d4707dd8 - Sigstore transparency entry: 179237440
- Sigstore integration time:
-
Permalink:
permguard/permguard-python@a7c62b15e9115ea8d28e3c09a4ad6ab56245b404 -
Branch / Tag:
refs/tags/v0.0.10 - Owner: https://github.com/permguard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
permguard-python-ci.yml@a7c62b15e9115ea8d28e3c09a4ad6ab56245b404 -
Trigger Event:
push
-
Statement type: