Denied SDK for Python
Project description
Denied SDK for Python
A lightweight Python SDK for the Denied authorization platform.
Installation
pip install denied-sdk
Quick Start
from denied_sdk import DeniedClient
client = DeniedClient(api_key="your-api-key")
result = client.check(
subject="user://alice",
action="read",
resource="document://secret",
)
print(result.decision) # True or False
print(result.context.reason) # Optional reason string
Configuration
| Parameter | Environment variable | Default | |
|---|---|---|---|
| Base URL | url |
DENIED_URL |
https://api.denied.dev |
| API Key | api_key |
DENIED_API_KEY |
- |
Configure the SDK by instancing the DeniedClient with the desired parameters.
# with constructor parameters
client = DeniedClient(
url="https://example.denied.dev",
api_key="your-api-key",
)
# or with environment variables
client = DeniedClient()
API Reference
check()
Check whether a subject has permissions to perform an action on a resource.
Signature:
client.check(subject, action, resource, context=None) -> CheckResponse
Arguments:
subject—Subjectobject,dict, or"type://id"stringaction—Actionobject,dict, or plain stringresource—Resourceobject,dict, or"type://id"stringcontext— optionaldictof additional context
Examples:
from denied_sdk import Action, Resource, Subject
# URI string shorthand — simplest
result = client.check(subject="user://alice", action="read", resource="document://123")
# Typed objects — full IDE support and Pydantic validation
result = client.check(
subject=Subject(type="user", id="alice", properties={"role": "admin"}),
action=Action(name="read"),
resource=Resource(type="document", id="123"),
context={"ip": "192.168.1.1"},
)
bulk_check()
Perform multiple authorization checks in a single request.
Signature:
client.bulk_check(check_requests: list[CheckRequest]) -> list[CheckResponse]
Examples:
from denied_sdk import Action, CheckRequest, Resource, Subject
results = client.bulk_check([
CheckRequest(
subject=Subject(type="user", id="alice"),
action=Action(name="read"),
resource=Resource(type="document", id="1"),
),
CheckRequest(
subject=Subject(type="user", id="bob"),
action=Action(name="write"),
resource=Resource(type="document", id="1"),
),
])
Types
Subject/Resource—type: str,id: str,properties: dict(optional)Action—name: str,properties: dict(optional)CheckRequest—subject,action,resource,context: dict(optional)CheckResponse—decision: bool,context(optional:reason: str,rules: list[str])
Async Client
from denied_sdk import AsyncDeniedClient
async with AsyncDeniedClient(api_key="your-api-key") as client:
result = await client.check(
subject="user://alice",
action="read",
resource="document://secret",
)
Requirements
Python >= 3.10
License
Apache-2.0
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 denied_sdk-0.5.0.tar.gz.
File metadata
- Download URL: denied_sdk-0.5.0.tar.gz
- Upload date:
- Size: 159.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
032841970930562e31e7f32f8da93fdbc457e2489612bfbe8dc962019da94421
|
|
| MD5 |
ca3aa964c3b2d275e62d02138378b742
|
|
| BLAKE2b-256 |
0cde8ed857c12e9e92ca7dd1e65fb3aff728acba1c10d4d7050a89f686db50d7
|
File details
Details for the file denied_sdk-0.5.0-py3-none-any.whl.
File metadata
- Download URL: denied_sdk-0.5.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2c5ae7128c0a538b4105734396e6fecec964a796125072d8bcfd4780e4f27b1
|
|
| MD5 |
5e6de13b3674e6b0e3b8511890cec105
|
|
| BLAKE2b-256 |
932e6b7d52451eae2b30cd7d90f2a704c00b72d2181f687db69f87a5b3b474b3
|