Module pdp implements a client for making authz requests to a Policy Decision Point (OPA)
Project description
opa-python-client
Abstract
build.security provides simple development and management for your organization's authorization policy. opa-python-client is a Python 3 package that performs authorization requests against build.security PDPs (Policy Decision Point)/OPA.
Data Flow
Usage
Before you start we recommend completing the onboarding tutorial.
Important note
To simplify the setup process, the following example uses a local build.security PDP instance. If you are already familiar with how to run your PDP, You can also run a PDP on your environment (Dev/Prod, etc).
In that case, don't forget to change the hostname and port in your code.
Simple usage
Initialize the client, initialize some input for the PDP, and make a request:
from from opaclient import PolicyDecisionPointClient, PolicyDecisionPointInput, AuthzException
client = PolicyDecisionPointClient(hostname='http://some.host', port=8181,
policy_path='mypolicy', read_timeout_milliseconds=100, connection_timeout_milliseconds=100,
retry_max_attempts=5, retry_backoff_milliseconds=1000)
input = PolicyDecisionPointInput(schema='http', method='POST', more_authz_context=some_value,
even_more_authz_context=some_other_value=some_other_value)
try:
authz = client.authorize(input)
except AuthzException as e:
raise
if authz:
print('The request has been authorized!')
Mandatory configuration to initialize the client
hostname- The hostname of the Policy Decision Point (PDP)port- The port at which the PDP service is serving authz decisionspolicy_path- Full path to the policy (including the rule) that decides whether requests should be authorized
How to get your pdp's hostname and port?
Optional configuration
retry_max_attempts- the maximum number of retry attempts in case a failure occurs. Default is 2.read_timeout_milliseconds- Read timeout for requests in milliseconds. Default is 5000connection_timeout_milliseconds- Connection timeout in milliseconds. Default is 5000retry_backoff_milliseconds- The number of milliseconds to wait between two consecutive retry attempts. Default is 250
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 opaclient-0.1.0.tar.gz.
File metadata
- Download URL: opaclient-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f5ed38d54e35121922193d48763912dc15c1e0d6b86c22464883310d0c6ec6b
|
|
| MD5 |
921123b5440d0b04b2b96f8b6078a1e5
|
|
| BLAKE2b-256 |
44aca14e1a1ca7f224acf1bed1c20db22cf689bdab772b049481ba384d11b907
|
File details
Details for the file opaclient-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: opaclient-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ea2a4bf8ea4e2d724992fe66fb54d187a61429b927d3f7b3164ff3238d74d0e
|
|
| MD5 |
97b5ae3f0af212ed8fd1116da19303fc
|
|
| BLAKE2b-256 |
1e6f67ad90f41d56ec85c6e10ed4f8c49280efb407588693582e4deb75b478a0
|