@@ -14,18 +14,19 @@ The `Duende.IdentityModel.OidcClient.Extensions` library adds supports for DPoP
14
14
15
15
## DPoP Key
16
16
17
- Before we begin, your application needs to have a DPoP key, in the form of a
17
+ Before we begin, your application needs to have a DPoP key in the form of a
18
18
JSON Web Key (or JWK). According to the [ DPoP specification] [ dpop-spec ] , this
19
19
key needs to use an asymmetric algorithm ("RS", "ES", or "PS" style).
20
20
21
21
:::note
22
- This means that the client application is responsible for creating the DPoP key,
22
+ The client application is responsible for creating the DPoP key,
23
23
rotating it, and managing its lifetime. For as long as there are access tokens
24
24
(and possibly refresh tokens) bound to a DPoP key, that key needs to remain
25
25
available to the client application.
26
26
:::
27
27
28
- Creating a JWK in .NET is pretty straightforward using the ` Duende.IdentityModel.OidcClient.Extensions ` library:
28
+ You can create a JWK in .NET using the ` Duende.IdentityModel.OidcClient.Extensions ` library.
29
+ The ` JsonWebKeys ` class has several static methods to help with creating JWKs using various algorithms.
29
30
30
31
``` csharp
31
32
// Program.cs
@@ -39,12 +40,18 @@ Console.WriteLine(jwk);
39
40
40
41
:::caution
41
42
In a production scenario, you'll want to store this JWK in a secure location
42
- and use DataProtection to further protect the JWK.
43
+ and use ASP.NET's [ data protection] ( https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/ ) to further
44
+ protect the JWK. See [ our data protection guide] ( /identityserver/deployment#aspnet-core-data-protection ) for more
45
+ information.
43
46
:::
44
47
45
48
## Initializing the OIDC client with DPoP support
46
49
47
- Now that we have a JWK, we need to extend the ` OidcClientOptions ` to configure DPoP:
50
+ We will need to extend the ` OidcClientOptions ` before we can use DPoP.
51
+
52
+ After creating the ` OidcClientOptions `
53
+ to connect our client application with the Identity Provider, we retrieve a JWK to use for DPoP, and add that JWK
54
+ to our ` options ` by calling the ` ConfigureDPoP ` extension method:
48
55
49
56
``` csharp
50
57
// Program.cs
@@ -70,13 +77,16 @@ var oidcClient = new OidcClient(options);
70
77
71
78
## Proof Tokens for the API
72
79
73
- After configuring the ` OidcClientOptions ` with DPoP support and creating an
80
+ Now that we've configured the ` OidcClientOptions ` with DPoP support and created an
74
81
` OidcClient ` instance, you can use this instance to create an ` HttpMessageHandler ` which
75
82
will:
76
83
77
84
- manage access and refresh tokens
78
85
- add DPoP proof tokens to HTTP requests
79
86
87
+ The ` OidcClient ` provides ` CreateDPoPHandler ` as a convenience method to create such a handler,
88
+ which can be used with the .NET ` HttpClient ` .
89
+
80
90
``` csharp
81
91
// Program.cs
82
92
var sessionRefreshToken = " ..." ; // read from a previous session, if any
0 commit comments