You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Restructure DPoP examples to match auth0-react pattern
- Change section title to 'Device-bound tokens with DPoP'
- Add detailed intro explaining DPoP security benefits
- Document browser API requirements (Crypto API, IndexedDB)
- List supported OAuth 2.0 flows
- Add important callouts about ES256, new sessions, and sender constraining
- Reorganize content to match auth0-react structure
- Move manual DPoP management under Advanced usage subsection
- Add clearer progression from simple to advanced usage
-[Device-bound tokens with DPoP](#device-bound-tokens-with-dpop)
12
12
-[Standalone Components and a more functional approach](#standalone-components-and-a-more-functional-approach)
13
13
14
14
## Add login to your application
@@ -381,17 +381,30 @@ export class AppComponent {
381
381
}
382
382
```
383
383
384
-
## DPoP (Demonstrating Proof-of-Possession)
384
+
## Device-bound tokens with DPoP
385
385
386
-
[DPoP](https://datatracker.ietf.org/doc/html/rfc9449) is a security mechanism that cryptographically binds access tokens to clients, providing protection against:
386
+
**Demonstrating Proof-of-Possession** —or simply **DPoP**— is a recent OAuth 2.0 extension defined in [RFC9449](https://datatracker.ietf.org/doc/html/rfc9449).
387
387
388
-
- **Token Theft** - Stolen tokens are cryptographically bound and unusable by attackers
389
-
- **Replay Attacks** - Tokens are tied to specific HTTP requests
390
-
- **Token Exfiltration** - Tokens require the client's private key to use
388
+
It defines a mechanism for securely binding tokens to a specific device using cryptographic signatures. Without it, **a token leak caused by XSS or other vulnerabilities could allow an attacker to impersonate the real user.**
391
389
392
-
### Enable DPoP
390
+
To support DPoP in `auth0-angular`, some APIs available in modern browsers are required:
393
391
394
-
To enable DPoP support, set `useDpop:true` in your Auth0 configuration:
392
+
- [Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Crypto): allows to create and use cryptographic keys, which are used to generate the proofs (i.e. signatures) required for DPoP.
393
+
394
+
- [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API): enables the use of cryptographic keys [without exposing the private material](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto#storing_keys).
395
+
396
+
The following OAuth 2.0 flows are currently supported by `auth0-angular`:
> Currently, only the `ES256` algorithm is supported.
404
+
405
+
### Enabling DPoP
406
+
407
+
DPoP is disabled by default. To enable it, set the `useDpop` option to `true` when configuring the SDK. For example:
395
408
396
409
```ts
397
410
import { NgModule } from'@angular/core';
@@ -402,82 +415,167 @@ import { AuthModule } from '@auth0/auth0-angular';
402
415
AuthModule.forRoot({
403
416
domain: 'YOUR_AUTH0_DOMAIN',
404
417
clientId: 'YOUR_AUTH0_CLIENT_ID',
418
+
useDpop: true, // 👈
405
419
authorizationParams: {
406
420
redirect_uri: window.location.origin,
407
-
audience: 'https://api.example.com',
408
421
},
409
-
useDpop: true, // Enable DPoP
410
422
}),
411
423
],
412
424
})
413
425
exportclassAppModule {}
414
426
```
415
427
416
-
### Using createFetcher (Recommended)
428
+
After enabling DPoP, **every new session using a supported OAuth 2.0 flow in Auth0 will begin transparently to use tokens that are cryptographically bound to the current browser**.
429
+
430
+
> [!IMPORTANT]
431
+
> DPoP will only be used for new user sessions created after enabling it. Any previously existing sessions will continue using non-DPoP tokens until the user logs in again.
432
+
>
433
+
> You decide how to handle this transition. For example, you might require users to log in again the next time they use your application.
434
+
435
+
> [!NOTE]
436
+
> Using DPoP requires storing some temporary data in the user's browser. When you log the user out with `logout()`, thisdataisdeleted.
437
+
438
+
> [!TIP]
439
+
>Ifallyourclientsarealreadyusing DPoP, youmaywanttoincreasesecuritybymakingAuth0rejectanynon-DPoPinteractions. See [thedocsonSenderConstraining](https://auth0.com/docs/secure/sender-constraining/configure-sender-constraining) for details.
The simplest way to make authenticated API calls with DPoP is using the `createFetcher` method. It automatically handles tokens, DPoP proofs, and nonce management:
> IfDPoPisenabled, a`dpopNonceId` **must** bepresentinthe`createFetcher()`parameters, sinceit's used to keep track of the DPoP nonces for each request.
472
517
473
-
When working with multiple APIs, create separate fetchers for each. Each fetcher manages its own nonces independently:
Yourimplementationwillbecalledwithastandard, ready-to-use [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object, which will contain any headers needed for authorization and DPoP usage (if enabled). Depending on your needs, you can use this object directly or treat it as a container with everything required to make the request your own way.
0 commit comments