keyGenerate Proof

Generate proof for DPoP token exchange.

circle-info

When to use: Use this when building a non-browser client or testing DPoP flows without a real frontend.

chevron-rightPrerequisiteshashtag

Client Flow Diagram

5-Line Core

Essential code to generate proof for DPoP token.

Step-by-Step

1

Generate Key

create generate_key.py (demo key generation, in prod environment the key should be stored in client side, e.g. for browser we can use IndexedDB):

2

Create Proof

create create_proof.py (making sure it uses the same key generated by generate_key.py):

3

Test The Code

Use this generated proof for accessing protected resource in Protect Your API page.

Proof Structure Table

Claim
Purpose

htm

HTTP method

htu

HTTP URL

jti

Replay prevention

ath

Access token hash

iat

Freshness

Common Pitfalls

Pitfall
Why It Happens
How to Fix

Generating a new key for every request

DPoP keys are misunderstood as per-request instead of per-client

Generate the key once and persist it; reuse the same key for token requests and API calls

Using different keys for token request and API access

Token binding (cnf.jkt) ties the token to a specific public key

Always use the same private key that was used when requesting the access token

Reusing the same DPoP proof

DPoP proofs are one-time use and include jti

Generate a new proof for every HTTP request

Missing ath claim for resource requests

ath is optional for token requests but required for resource access

Include the access token when calling create_proof() for API requests

Incorrect HTTP method or URL in proof

Proofs bind to exact htm and htu values

Ensure the method and URL exactly match the outgoing HTTP request

Forgetting to handle nonce challenges

Some servers require nonce-based replay protection

On 401 + DPoP-Nonce, regenerate the proof including the nonce and retry

Treating DPoP as a browser-only feature

DPoP is often assumed to be frontend-only

Non-browser clients must explicitly manage key storage and proof generation

Production Notes

circle-exclamation

Guidelines for Production Deployments

  • Enable DPoP Only on HTTPS Endpoints Use HTTPS to transmit DPoP proofs and tokens securely via HTTP headers, preventing interception and replay attacks.

  • Decide on DPoP Requirement During migration, support both bearer and DPoP tokens. For production, set:

    This setting helps fully prevent bearer-token replay attacks.

  • Enable Nonce Protection for High-Security APIs Use nonce enforcement for an extra replay protection layer, especially for:

    • Financial operations

    • Privileged admin APIs

    • Internet-facing services

  • Separate DPoP from Authorization DPoP ensures token possession but not permission. Continuously enforce:

    • Role checks

    • Organization membership

    • Resource-level authorization

  • Monitor and Log DPoP Validation Failures Look out for potential issues such as:

    • Client misconfiguration

    • Replay attempts

    • Token theft attempts Ensure these events are observable in production logs and metrics.

  • Thoroughly Test with Real Clients Beyond Python scripts for testing and CI, validate production readiness using:

    • Browser-based clients

    • Mobile apps

    • Real HTTP stacks with retries and concurrency


circle-info

Found an issue on this page? Report it on our feedback formarrow-up-right.

Last updated

Was this helpful?