|
| 1 | +--- |
| 2 | +name: auth0-dpop |
| 3 | +description: Use when adding DPoP (Demonstrating Proof-of-Possession) token binding to protect API calls with device-bound, sender-constrained access tokens that cannot be replayed if stolen. Also use when a user says "bind tokens to the client", "prevent token theft", or "sender-constrained tokens". |
| 4 | +license: Apache-2.0 |
| 5 | +metadata: |
| 6 | + author: Auth0 <support@auth0.com> |
| 7 | + version: '1.0.0' |
| 8 | + openclaw: |
| 9 | + emoji: "\U0001F511" |
| 10 | + homepage: https://github.com/auth0/agent-skills |
| 11 | + requires: |
| 12 | + bins: |
| 13 | + - auth0 |
| 14 | + os: |
| 15 | + - darwin |
| 16 | + - linux |
| 17 | + install: |
| 18 | + - id: brew |
| 19 | + kind: brew |
| 20 | + package: auth0/auth0-cli/auth0 |
| 21 | + bins: [auth0] |
| 22 | + label: 'Install Auth0 CLI (brew)' |
| 23 | +--- |
| 24 | + |
| 25 | +# Auth0 DPoP Guide |
| 26 | + |
| 27 | +Bind access tokens to the client's cryptographic key so stolen tokens cannot be replayed. |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Overview |
| 32 | + |
| 33 | +### What is DPoP? |
| 34 | + |
| 35 | +DPoP (Demonstrating Proof-of-Possession) is an OAuth 2.0 mechanism defined in |
| 36 | +[RFC 9449](https://datatracker.ietf.org/doc/html/rfc9449) that cryptographically |
| 37 | +binds access tokens to a client-held key pair. Each API request includes a |
| 38 | +short-lived signed JWT (the DPoP proof) that proves the sender holds the private |
| 39 | +key — a stolen token alone cannot be replayed by an attacker. |
| 40 | + |
| 41 | +### When to Use This Skill |
| 42 | + |
| 43 | +- Protecting high-value API calls against token theft and replay attacks |
| 44 | +- Meeting security or compliance requirements that mandate sender-constrained tokens |
| 45 | +- Any SPA or Vanilla JS app calling a protected Auth0 API with elevated security needs |
| 46 | + |
| 47 | +### When NOT to Use This Skill |
| 48 | + |
| 49 | +- **SSR / server-side environments** — DPoP relies on a private key held in the browser; it cannot be safely used server-side (Next.js, Nuxt, etc.) |
| 50 | +- **APIs that don't support DPoP** — the resource server must be configured to accept DPoP token dialect; Bearer-only APIs will reject DPoP proofs |
| 51 | +- **Flows requiring token sharing** — DPoP tokens are bound to a single key pair and cannot be forwarded to or reused by another client |
| 52 | + |
| 53 | +### Requirements |
| 54 | + |
| 55 | +- Auth0 tenant with DPoP-capable authorization server |
| 56 | +- API resource server with DPoP token dialect enabled |
| 57 | +- A browser SPA using one of: `@auth0/auth0-vue`, `@auth0/auth0-react`, |
| 58 | + `@auth0/auth0-angular`, or `@auth0/auth0-spa-js` |
| 59 | +- HTTPS in production (required by Auth0 for DPoP) |
| 60 | + |
| 61 | +### Key Concepts |
| 62 | + |
| 63 | +| Concept | Description | |
| 64 | +|---------|-------------| |
| 65 | +| DPoP Proof | A short-lived signed JWT attached to each request proving key possession | |
| 66 | +| DPoP Nonce | A server-issued value that must be included in the proof to prevent replay | |
| 67 | +| `useDpop: true` | SDK option that enables automatic DPoP proof generation | |
| 68 | +| `createFetcher()` | SDK helper that returns a `fetch`-compatible function handling proofs automatically | |
| 69 | +| `UseDpopNonceError` | Error thrown when the server rotates its nonce mid-flight; retry with the new nonce | |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Step 1: Enable DPoP on Your API |
| 74 | + |
| 75 | +### Via Auth0 Dashboard |
| 76 | + |
| 77 | +1. Go to **Applications → APIs** |
| 78 | +2. Select the API your SPA calls |
| 79 | +3. Under the **Settings** tab, confirm the API identifier matches your `audience` |
| 80 | +4. No additional toggle is needed in the dashboard — DPoP is enabled per-request |
| 81 | + by the client when the API resource server is configured to accept DPoP tokens |
| 82 | + |
| 83 | +### Via Auth0 CLI |
| 84 | + |
| 85 | +```bash |
| 86 | +# Inspect current resource server settings |
| 87 | +auth0 api get "resource-servers" | jq '.[] | select(.identifier == "https://your-api-identifier")' |
| 88 | + |
| 89 | +# Enable DPoP token dialect on the API |
| 90 | +auth0 api patch "resource-servers/{API_ID}" \ |
| 91 | + --data '{"token_dialect": "access_token_authz"}' |
| 92 | +``` |
| 93 | + |
| 94 | +> Replace `{API_ID}` with the ID returned from the GET call above. |
| 95 | +
|
| 96 | +--- |
| 97 | + |
| 98 | +## Step 2: Configure Your Application |
| 99 | + |
| 100 | +### Common pattern across all frameworks |
| 101 | + |
| 102 | +1. Add `useDpop: true` to your Auth0 client/provider configuration alongside your `audience` |
| 103 | +2. Use `createFetcher()` instead of attaching tokens manually — the SDK handles |
| 104 | + proof generation, nonce management, and header injection for you |
| 105 | +3. Handle `UseDpopNonceError` in cases where the server rotates its nonce |
| 106 | + |
| 107 | +### Environment variables |
| 108 | + |
| 109 | +Ensure your `.env` includes the API audience: |
| 110 | + |
| 111 | +```bash |
| 112 | +# Vite |
| 113 | +VITE_AUTH0_DOMAIN=your-tenant.auth0.com |
| 114 | +VITE_AUTH0_CLIENT_ID=your-client-id |
| 115 | +VITE_AUTH0_AUDIENCE=https://your-api-identifier |
| 116 | +``` |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Additional Resources |
| 121 | + |
| 122 | +### [Framework Examples](references/examples.md) |
| 123 | +Complete implementation examples for all supported frameworks: |
| 124 | +- Vue.js |
| 125 | +- React |
| 126 | +- Angular |
| 127 | +- auth0-spa-js (Vanilla JS) |
| 128 | + |
| 129 | +### [Integration Guide](references/integration.md) |
| 130 | +Error handling and troubleshooting: |
| 131 | +- `UseDpopNonceError` — nonce rotation handling |
| 132 | +- Common issues |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +## Related Skills |
| 137 | + |
| 138 | +- `auth0-vue` - Vue.js Auth0 integration |
| 139 | +- `auth0-react` - React Auth0 integration |
| 140 | +- `auth0-angular` - Angular Auth0 integration |
| 141 | +- `auth0-spa-js` - Vanilla JS / framework-agnostic SPA integration |
| 142 | +- `auth0-mfa` - Multi-factor authentication |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## References |
| 147 | + |
| 148 | +- [Auth0 DPoP Documentation](https://auth0.com/docs/secure/tokens/access-tokens/dpop) |
| 149 | +- [RFC 9449 — OAuth 2.0 Demonstrating Proof of Possession](https://datatracker.ietf.org/doc/html/rfc9449) |
| 150 | +- [auth0-spa-js Releases](https://github.com/auth0/auth0-spa-js/releases) |
0 commit comments