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
Reformatted paragraphs and lists for better readability and structure. Enhanced the DPoP validation section with a detailed step-by-step breakdown and added code examples for implementing validation using the `Duende.AspNetCore.Authentication.JwtBearer` NuGet package.
IdentityServer can [bind tokens to clients](/identityserver/tokens/pop#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#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.
14
17
15
18
### Validating mTLS
16
19
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.
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:
32
39
33
40
```cs
34
41
publicstaticclassConfirmationValidationExtensions
@@ -109,11 +116,31 @@ public class ConfirmationValidationMiddlewareOptions
109
116
```
110
117
111
118
### 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.
115
119
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.
0 commit comments