Skip to main content

pydpop

RFC 9449 DPoP (Demonstrating Proof of Possession) for Python — proof generation and verification, in one tiny dependency-light package. v0.2 adds post-quantum hybrid proofs (ML-DSA + ES256) — the first PQC-ready Python DPoP library.

Why does this exist? It's 2026 and Python still has no production-ready DPoP library. Authlib's DPoP issue has been open since 2021. Every Python shop rolling OAuth 2.1 / MCP servers with sender-constrained tokens is hand-rolling proofs or skipping DPoP entirely. This fills that gap.

Quickstart

from pydpop import generate_key, generate_proof, verify_proof, MemoryJtiStore

# --- client side: sign one proof per HTTP request ---
key = generate_key()  # keep this private, persist it yourself
proof = generate_proof(
    private_key=key,
    htm="POST",
    htu="https://auth.example.com/token",
)
headers = {"DPoP": proof}

# --- server side: verify ---
store = MemoryJtiStore()  # replay cache; use Redis/DB in production
bound = verify_proof(
    proof=proof,
    htm="POST",
    htu="https://auth.example.com/token",
    jti_store=store,
)
print(bound["jwk_thumbprint"])  # compare against the access token's cnf.jkt

With an access token bound to the proof (ath claim):

proof = generate_proof(private_key=key, htm="GET",
                       htu="https://api.example.com/data",
                       access_token="the-access-token")
verify_proof(proof=proof, htm="GET", htu="https://api.example.com/data",
             access_token="the-access-token")

Five minutes to production

Two complete paths; the Quickstart above is the manual version.

Protect a FastAPI resource server — pip install pydpop[fastapi]:

from fastapi import Depends, FastAPI
from pydpop.integrations.fastapi import DPoPVerifier

app = FastAPI()
verify_dpop = DPoPVerifier()  # share one instance: shared replay cache

@app.get("/data")
def read_data(bound=Depends(verify_dpop)):
    # bound == {"jwk", "jwk_thumbprint", "claims"}; compare
    # bound["jwk_thumbprint"] to the access token's cnf.jkt
    ...

Any bad proof → 401 WWW-Authenticate: DPoP (fail closed).

Protect an httpx client — pip install pydpop[httpx]:

import httpx
from pydpop import generate_key
from pydpop.integrations.httpx import DPoPAuth

client = httpx.Client(auth=DPoPAuth(generate_key()))
client.post("https://auth.example.com/token", data={...})  # proof attached, nonce retried

Every request gets a fresh proof; DPoP-Nonce challenges are retried once, automatically. Full detail for both paths: docs/integrations.md.

Scope

v0.1 — pure RFC 9449: ES256 (P-256) proof generation, full server-side verification (typ, alg, signature, htm/htu, iat window, jti replay cache, nonce, ath binding), RFC 7638 JWK thumbprints.

v0.2 — hybrid post-quantum DPoP: ML-DSA-44-ES256 (default hybrid, proofs fit 8 KB headers) and ML-DSA-65-ES256 (opt-in), per draft-ietf-jose-pq-composite-sigs + RFC 9964, with select_alg() negotiation against the AS's dpop_signing_alg_values_supported. See docs/pqc.md. Still one dependency (cryptography); ES256 behavior unchanged.

Verification checklist

  • Round-trip: generate → verify
  • Negative tests: tampered payload, wrong htm/htu, stale iat, replayed jti, ath/nonce mismatch, JWK substitution
  • Interop against Keycloak 26.4+ (DPoP-capable) — verified against Keycloak 26.8.0, see docs/interop-keycloak.md

Interoperability profile

docs/python-dpop-profile.md is the Python DPoP Interoperability Profile (pydpop-profile/1): the deployment contract for stateless and stateful servers, the fixed verification order (jti is consumed only at the final commit point, after signature, htm/htu, iat, nonce and ath), the RFC 8693 token-exchange boundary, and the accurate failure modes of the in-memory replay store. The security invariants are executable — python -m pytest tests/test_invariants.py -v. The 28-case conformance vectors live in conformance/vectors/vectors.json (python conformance/run.py --vectors, 28/28); pydpop serve --conformance exposes them over HTTP for other languages' interop tests.

FAQ

I use httpx — do I have to mint proofs manually? No: pip install pydpop[httpx] and use DPoPAuth — every request is signed, DPoP-Nonce retries are automatic. See docs/integrations.md.

I'm building a FastAPI resource server — how do I verify DPoP? pip install pydpop[fastapi] and use DPoPVerifier as a Dependency — 401s fail closed, replay cache shared. Same doc.

Django? pip install pydpop[django] and add DPoPMiddleware — same guarantees, plus @dpop_exempt for public views.

Flask / Starlette? pip install pydpop[flask] (DPoPVerifier + g.dpop) or pip install pydpop[starlette] (ASGI middleware, scope["dpop"]). aiohttp? pip install pydpop[aiohttp] (DPoPClientSession, same auto-signing as the httpx one).

DPoP for Bluesky/ATProto in Python? ATProto mandates DPoP-bound tokens and the ecosystem hand-rolls it (badly — see the cookbook bugs). docs/atproto.md is the recipe; DPoPAuth is the drop-in layer.

How do I implement DPoP in Python? Use this library — Authlib has no DPoP support (issue #315 open since 2021). pip install pydpop, then the Quickstart above.

Is there a post-quantum DPoP library for Python? Yes — this one. v0.2 adds hybrid ML-DSA-44-ES256 / ML-DSA-65-ES256 proofs (draft-ietf-jose-pq-composite-sigs + RFC 9964), still with a single dependency. See docs/pqc.md.

DPoP for MCP servers? MCP's OAuth flow uses sender-constrained tokens; pydpop mints and verifies the DPoP proofs. Pair with MemoryJtiStore (or your Redis) for replay protection.

Do I need this if my provider already does OAuth? If your tokens are bearer tokens, anyone who steals one can use it. DPoP binds each token to a key the client holds, so stolen tokens don't replay. That's the whole point of RFC 9449.

Contributing

Issues and PRs welcome — especially interop reports against real authorization servers. Run pytest before submitting.

License

MIT

Metadata

Release files for pydpop 0.2.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 pydpop 0.2.2
File Size Uploaded Provenance Actions
pydpop-0.2.2.tar.gz 197.6 kB With provenance Details for pydpop-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydpop 0.2.2
File Interpreter ABI Platform Actions
pydpop-0.2.2-py3-none-any.whl Python 3 none any Details for pydpop-0.2.2-py3-none-any.whl

Total release size: 246.4 kB

Release files / pydpop-0.2.2.tar.gz

Download URL pydpop-0.2.2.tar.gz
Size 197.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8905480e315421582887ce98cf06cff52c68cf55196206435a9f20ed9ed111b7
BLAKE2b-256 checksum
How to use checksums
5e2ba0daf3652d0640a49f2a1e94a488ae7be9444353081030f06d46292f4c83
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 Nov 24, 2026.

Transparency log

Release files / pydpop-0.2.2-py3-none-any.whl

Download URL pydpop-0.2.2-py3-none-any.whl
Size 48.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f420218dbd3368ef8e58eae1309f23b402bbf9ba5a34767dd20207665c0a0996
BLAKE2b-256 checksum
How to use checksums
e07c64556dfa05944d893ff000db08c61b7dffa3f29e1d65482190ffa6df103e
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 Nov 24, 2026.

Transparency log

Security for pydpop 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydpop-0.2.2.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 Nov 24, 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