Skip to content

Commit 304c9f2

Browse files
Merge branch 'main' into markdown-extensions-support
2 parents 3db0552 + 7ef7cb2 commit 304c9f2

12 files changed

Lines changed: 387 additions & 96 deletions

File tree

.idea/docs.duendesoftware.com.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/accesstokenmanagement/advanced/DPoP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ services.AddClientCredentialsTokenManagement()
5757
Once the key has been configured for the client, then the library will use it to produce a DPoP proof token when calling the token server (including token renewals if relevant).
5858
There is nothing explicit needed on behalf of the developer using this library.
5959

60-
### `dpop_jkt` At The token Server's Authorize Endpoint
60+
### `dpop_jkt` At The Token Server's Authorize Endpoint
6161

6262
When using DPoP and `AddOpenIdConnectAccessTokenManagement`, this library will also automatically include the `dpop_jkt` parameter to the authorize endpoint.
6363

src/content/docs/identitymodel/endpoints/dynamic-registration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ redirect_from:
88
- /foss/identitymodel/endpoints/dynamic_registration/
99
---
1010

11-
The client library for [OpenID Connect Dynamic Client
12-
Registration](https://openid.net/specs/openid-connect-registration-1_0.html)
13-
is provided as an extension method for *HttpClient*.
11+
The client library for [OpenID Connect Dynamic Client Registration](https://openid.net/specs/openid-connect-registration-1_0.html)
12+
is provided as an extension method for [
13+
`System.Net.Http.HttpClient`](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient).
1414

1515
The following code sends a registration request:
1616

src/content/docs/identitymodel/utils/base64.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ bytes = WebEncoders.Base64UrlDecode(b64url);
3737

3838
var text = Encoding.UTF8.GetString(bytes);
3939
Console.WriteLine(text);
40+
```
41+
42+
## IdentityModel's Base64Url
4043

4144
IdentityModel includes the *Base64Url* class to help with
4245
encoding/decoding:

src/content/docs/identityserver/apis/aspnetcore/confirmation.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ redirect_from:
1010
- /identityserver/v7/apis/aspnetcore/confirmation/
1111
---
1212

13-
IdentityServer can [bind tokens to clients](/identityserver/tokens/pop.md#proof-of-possession-styles) using either mTLS or DPoP, creating a `Proof-of-Possession` (PoP) access token. When one of these mechanisms is used, APIs that use those access tokens for authorization need to validate the binding between the client and token. This document describes how to perform such validation, depending on which mechanism was used to produce a PoP token.
13+
IdentityServer can [bind tokens to clients](/identityserver/tokens/pop.md#proof-of-possession-styles) using either mTLS or
14+
DPoP, creating a `Proof-of-Possession` (PoP) access token. When one of these mechanisms is used, APIs that use those
15+
access tokens for authorization need to validate the binding between the client and token. This document describes how
16+
to perform such validation, depending on which mechanism was used to produce a PoP token.
1417

1518
### Validating mTLS
1619

17-
If you are using a [mutual TLS connection](/identityserver/tokens/pop#mutual-tls) to establish proof-of-possession, the resulting access token will contain a `cnf` claim containing the client's certificate thumbprint. APIs validate such tokens by comparing this thumbprint to the thumbprint of the client certificate in the mTLS connection. This validation should be performed early in the pipeline, ideally immediately after the standard validation of the access token.
20+
If you are using a [mutual TLS connection](/identityserver/tokens/pop#mutual-tls) to establish proof-of-possession, the
21+
resulting access token will contain a `cnf` claim containing the client's certificate thumbprint. APIs validate such
22+
tokens by comparing this thumbprint to the thumbprint of the client certificate in the mTLS connection. This validation
23+
should be performed early in the pipeline, ideally immediately after the standard validation of the access token.
1824

1925
You can do so with custom middleware like this:
2026

@@ -28,7 +34,8 @@ app.UseConfirmationValidation();
2834
app.UseAuthorization();
2935
```
3036

31-
Here, `UseConfirmationValidation` is an extension method that registers the middleware that performs the necessary validation:
37+
Here, `UseConfirmationValidation` is an extension method that registers the middleware that performs the necessary
38+
validation:
3239

3340
```cs
3441
public static class ConfirmationValidationExtensions
@@ -109,11 +116,31 @@ public class ConfirmationValidationMiddlewareOptions
109116
```
110117

111118
### Validating DPoP
112-
If you are using [DPoP](/identityserver/tokens/pop) for proof-of-possession, there is a non-trivial amount of work needed to validate the `cnf` claim.
113-
In addition to the normal validation mechanics of the access token itself, DPoP requires additional validation of the DPoP proof token sent in the "DPoP" HTTP request header.
114-
DPoP proof token processing involves requiring the DPoP scheme on the authorization header where the access token is sent, JWT validation of the proof token, "cnf" claim validation, HTTP method and URL validation, replay detection (which requires some storage for the replay information), nonce generation and validation, additional clock skew logic, and emitting the correct response headers in the case of the various validation errors.
115119

116-
You can use the `Duende.AspNetCore.Authentication.JwtBearer` NuGet package to implement this validation. With this package, the configuration necessary in your startup can be as simple as this:
120+
When using [DPoP](/identityserver/tokens/pop#enabling-dpop-in-identityserver) for proof-of-possession, validating the `cnf` claim requires several
121+
steps:
122+
123+
1. Validating the access token as normal
124+
2. Validating the DPoP proof token from the `DPoP` HTTP request header
125+
3. Ensuring the authorization header uses the DPoP scheme
126+
4. Validating the JWT format of the proof token
127+
5. Verifying the `cnf` claim matches between tokens
128+
6. Validating the HTTP method and URL match the request
129+
7. Detecting replay attacks using storage
130+
8. Managing nonce generation and validation
131+
9. Handling clock skew between systems
132+
10. Returning appropriate error response headers when validation fails
133+
134+
This comprehensive validation process requires careful implementation to ensure security. Luckily for
135+
developers, we've implemented these steps into an easy-to-use library.
136+
137+
You can use the `Duende.AspNetCore.Authentication.JwtBearer` NuGet package to implement this validation.
138+
139+
```bash
140+
dotnet add package Duende.AspnetCore.Authentication.JwtBearer
141+
```
142+
143+
With this package, the configuration necessary in your startup can be as simple as this:
117144

118145
```cs
119146
// adds the normal JWT bearer validation
@@ -132,8 +159,8 @@ builder.Services.ConfigureDPoPTokensForScheme("token");
132159
```
133160

134161
You will also typically need a distributed cache, used to perform replay detection of DPoP
135-
proofs. Duende.AspNetCore.Authentication.JwtBearer relies on `IDistributedCache` for this,
136-
so you can supply the cache implementation of your choice. See the
162+
proofs. `Duende.AspNetCore.Authentication.JwtBearer` relies on `IDistributedCache` for this,
163+
so you can supply the cache implementation of your choice. See the
137164
[Microsoft documentation](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-8.0)
138165
for more details on setting up distributed caches, along with many examples, including Redis, CosmosDB, and
139166
Sql Server.

src/content/docs/identityserver/quickstarts/3a-token-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Given that the access token has a finite lifetime, you typically want to
2929

3030
ASP.NET Core has built-in facilities that can help you with some of those tasks
3131
(like caching or sessions), but there is still quite some work left to do.
32-
[Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki)
32+
[Duende.AccessTokenManagement](/accesstokenmanagement)
3333
can help. It provides abstractions for storing tokens, automatic refresh of expired tokens, etc.
3434

3535
## Requesting A Refresh Token

src/content/docs/identityserver/samples/basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Key takeaways:
7575
### MVC Client with automatic Access Token Management
7676

7777
This sample shows how to
78-
use [Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki) to automatically
78+
use [Duende.AccessTokenManagement](/accesstokenmanagement) to automatically
7979
manage access tokens.
8080

8181
The sample uses a special client in the sample IdentityServer with a short token lifetime (75 seconds). When repeating

src/content/docs/identityserver/tokens/pop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ new Client
200200
#### Enabling DPoP Support In Your Client
201201

202202
The easiest approach for supporting DPoP in your client is to use the DPoP support in the `Duende.AccessTokenManagement`
203-
library ([docs available here](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki/DPoP)).
203+
library ([docs available here](/accesstokenmanagement/advanced/dpop/)).
204204
It provides DPoP client support for both client credentials and code flow style clients.
205205
DPoP is enabled by assigning the `DPoPJsonWebKey` on the client configuration.
206206

src/content/docs/identityserver/tokens/refresh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var response = await client.RequestRefreshTokenAsync(new RefreshTokenRequest
6363
});
6464
```
6565

66-
The [Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki) library can be
66+
The [Duende.AccessTokenManagement](/accesstokenmanagement) library can be
6767
used to automate refresh & access token lifetime management in ASP.NET Core.
6868

6969
## Binding Refresh Tokens

src/content/docs/identityserver/tokens/requesting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var response = await client.RequestClientCredentialsTokenAsync(new ClientCredent
7171

7272
### Automating Token Requests In ASP.NET Core And Worker Applications
7373

74-
The [Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki) library can automate client credential request and token lifetime management for you.
74+
The [Duende.AccessTokenManagement](/accesstokenmanagement) library can automate client credential request and token lifetime management for you.
7575
Using this library, you can enable access token management for an HTTP client provided by `IHttpClientFactory`.
7676

7777
You can add the necessary services to ASP.NET Core's service provider by calling `AddClientCredentialsTokenManagement()`. One or more named client definitions need to be registered by calling `AddClient()`.
@@ -228,4 +228,4 @@ builder.Services.AddAuthentication(options =>
228228
```
229229

230230
### Automating Token Management In ASP.NET Core
231-
The [Duende.AccessTokenManagement](https://github.com/DuendeSoftware/Duende.AccessTokenManagement/wiki) library can also be used to automate token lifetime management in ASP.NET Core applications for you.
231+
The [Duende.AccessTokenManagement](/accesstokenmanagement) library can also be used to automate token lifetime management in ASP.NET Core applications for you.

0 commit comments

Comments
 (0)