Skip to main content

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 — Subject object, dict, or "type://id" string
  • action — Action object, dict, or plain string
  • resource — Resource object, dict, or "type://id" string
  • context — optional dict of 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

Metadata

Release files for denied-sdk 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for denied-sdk 0.5.2
File Size Uploaded Provenance
denied_sdk-0.5.2.tar.gz 159.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for denied-sdk 0.5.2
File Interpreter ABI Platform
denied_sdk-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 185.0 kB

Release files / denied_sdk-0.5.2.tar.gz

Download URL denied_sdk-0.5.2.tar.gz
Size 159.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a420717616af0a9fce9da109e42853ddf5916230431a345aab340d2775be1af1
BLAKE2b-256 checksum
How to use checksums
95fb5b9601bf48151cb1201756aad0b78869abda595274289b2f17d77aac2a63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release files / denied_sdk-0.5.2-py3-none-any.whl

Download URL denied_sdk-0.5.2-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
caa6920630611e921c415a3b97a33d1bccdae1f9f83414e9385520c096c8296f
BLAKE2b-256 checksum
How to use checksums
5d93918f244e9788444109e891f0a41f487ed3a4a858feb6c8c63f1c491e612a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Security for denied-sdk 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page