Skip to main content

konklav-relying

Decide Konklav authorization locally from Python.

Konklav is a standalone identity and access service. This package is the Python SDK for relying systems: services that accept Konklav's tokens and need authorization decisions for them. It verifies tokens offline, caches entitlements and keeps them fresh from Konklav's change feed, so most decisions need no network round trip.

Installing

pip install konklav-relying

Wheels are published for Python 3.12 and later on:

  • Linux x86_64 and aarch64 with glibc 2.28 or later (manylinux_2_28)
  • Linux x86_64 and aarch64 with musl 1.2 or later, such as Alpine (musllinux_1_2)
  • macOS on Apple silicon

Elsewhere pip builds from the sdist, which needs a Rust toolchain.

Usage

from konklav_relying import RelyingClient

client = RelyingClient(
    relying_url="https://konklav:8081",
    subject_url="https://konklav:8080",
    key_id=key_id,
    secret=secret,
    issuer="https://auth.example",
    audiences={"api", "app"},
)
await client.start()

decision = await client.decide(
    token,
    {"scopes": [{"kind": "project", "id": project_id, "actions": ["document:read"]}]},
)
if decision["decision"] != "allow":
    ...

await client.stop()

RelyingClient runs on asyncio with httpx:

  • It logs in as a service principal and follows the change feed in the background, so revocations and entitlement changes take effect within about a second.

  • It decides locally, and falls back to Konklav's check API whenever its caches can't be trusted, for example while the feed is disconnected.

  • KonklavError means Konklav could not be reached or answered with an error. Treat it as a deny.

  • await_cursor waits until a change you just made through Konklav has reached the cache, for read-your-writes.

  • decide_request and verify_request take a request's raw Authorization and DPoP headers, its method and the public URL, so sender-constrained (DPoP) tokens work too. A deny with reason invalid_dpop_proof should be answered with 401 and WWW-Authenticate: DPoP error="invalid_dpop_proof".

  • accept_request verifies a request's token, session and DPoP proof once and returns the verified token, and decide_accepted then decides for it without spending the proof again, as often as the request needs, for hosts that need the token before they know the requirements or that decide more than once; release_accepted ends it once the request is answered. Pass route=True for the decision of the request's route: its allow vouches, through the catalog's vouches, for actions the request's later decisions then pass, such as a handler's user:write check on a route requiring user:manage_data.

  • Policy declares an operation's requirements once per route or router, merges the policies of nested layers and resolves them per request with the scope ids it names. decide_typed, decide_request_typed, verify_typed and verify_request_typed return a Decision and an AccessToken instead of JSON:

    policy = Policy(tenant_actions={"project:read"}, tenant_facts={"tenant_type": ["client"]})
    decision = await client.decide_typed(token, policy.requirements())
    if not decision.allowed:
        ...
    

For a relying system's own endpoints that could reveal whether a record exists, such as inviting an address or starting a password reset:

  • paced(Pacing(floor, jitter)), an async context manager and decorator, answers no sooner than floor ± jitter (drawn from secrets), also when the work raises. Cancellation isn't paced. Tests use Pacing.NONE.
  • fake_uuid7() makes a UUIDv7 to answer with in place of one that wasn't created, claiming now; fake_uuid7(within=timedelta(days=365)) claims a random time in the past year, for records that would already exist.
from datetime import timedelta

from konklav_relying import Pacing, fake_uuid7, paced

pacing = Pacing(floor=timedelta(milliseconds=800), jitter=timedelta(milliseconds=200))

async def invite(address: str) -> str:
    async with paced(pacing):
        member = await find_member(address)
        return str(await send_invite(member) if member else fake_uuid7())

The decision logic lives in a Rust core shared with Konklav's other relying bindings, so they can't disagree. Python does only the I/O.

Rate limits

RateLimit bounds how often events may happen per key, over several windows. With the redis extra (pip install konklav-relying[redis]), every process sharing a Valkey or Redis server enforces one limit together, and falls back to counting in memory while it is unavailable:

login = RateLimit(
    "login",
    [RateLimitWindow(size=5, period=timedelta(minutes=1))],
    redis=redis.asyncio.Redis.from_url(redis_url),
    secret=rate_limit_secret,
)
try:
    await login.add(email)
except RateLimited as limited:
    ...  # retry after limited.retry_after

Versions

The package has the same version as the Konklav server it was released with. Pre-releases, such as 1.3.0rc1, are installed only with pip install --pre.

MIT licensed.

Metadata

Release files for konklav-relying 1.13.0

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

Source distribution (sdist)

Source distribution for konklav-relying 1.13.0
File Size Uploaded Provenance Actions
konklav_relying-1.13.0.tar.gz 184.3 kB With provenance Details for konklav_relying-1.13.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for konklav-relying 1.13.0
File Actions
konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_x86_64.whl CPython 3.12 abi3 Linux musl 1.2+ x86-64 Details for konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_x86_64.whl
konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_aarch64.whl CPython 3.12 abi3 Linux musl 1.2+ ARM64 Details for konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_aarch64.whl
konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details for konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_x86_64.whl
konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details for konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_aarch64.whl
konklav_relying-1.13.0-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for konklav_relying-1.13.0-cp312-abi3-macosx_11_0_arm64.whl

Total release size: 4.5 MB

Release files / konklav_relying-1.13.0.tar.gz

Download URL konklav_relying-1.13.0.tar.gz
Size 184.3 kB
Tags Source
SHA-256 checksum
How to use checksums
261f9ef3c2d49f6e09fed85274da235d56c2119aab974e841eea261e3b304639
BLAKE2b-256 checksum
How to use checksums
3f74d037cbf416ba66c7f027469465d40942c3bc4f80339c0484bf6ededccb59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_x86_64.whl

Download URL konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
071e1cc1eeb9afed7e17b20ef82c8975be6e40d74af459cea375d84f54b8d470
BLAKE2b-256 checksum
How to use checksums
73e2b5deb6765955fe5752839992a086a7ff8af2b8984828ca4539c1315c71e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_aarch64.whl

Download URL konklav_relying-1.13.0-cp312-abi3-musllinux_1_2_aarch64.whl
Size 949.9 kB
Tags CPython 3.12 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
704c014d1acf046da3c3fae8bd6f9b01c8674a7c9d49d10d34b603d44041c98f
BLAKE2b-256 checksum
How to use checksums
960795d6e17405e33981a9cab5cff412a000474a5b5a3afe93f49d65a589d4ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_x86_64.whl
Size 847.8 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
4214b835cbd9309c9db68e7799691891f6a0258f244d36b8710366a37fdeb35e
BLAKE2b-256 checksum
How to use checksums
db116f09a488b8fffa8b70342679fdef95e09e4f50b9f9c2dc59ec6c1de42c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL konklav_relying-1.13.0-cp312-abi3-manylinux_2_28_aarch64.whl
Size 772.9 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
98b01079cce02f58a43705e199fb32a3aa21dd4d7c19082b5c3daa7855bbe1aa
BLAKE2b-256 checksum
How to use checksums
ab64ffdbc0b7ff5ad28e71866bc473e0eb3bfb604b8e3f2065125ba73abc2f6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / konklav_relying-1.13.0-cp312-abi3-macosx_11_0_arm64.whl

Download URL konklav_relying-1.13.0-cp312-abi3-macosx_11_0_arm64.whl
Size 726.6 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c6fc7626938c92c4e954768f906e5bf2db52b946c8a7820d4e7a8ed92a9111ea
BLAKE2b-256 checksum
How to use checksums
522909738a1313e22ddffdad98de4eda9a72cf76840e91d410b65a0c88ee7adc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for konklav-relying 1.13.0

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for konklav_relying-1.13.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

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