Skip to content

Commit d9f392b

Browse files
committed
Code review updates
1 parent 0245314 commit d9f392b

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

src/content/docs/identitymodel/endpoints/introspection.mdx

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ description: Learn how to use the OAuth 2.0 token introspection endpoint to vali
44
sidebar:
55
order: 4
66
label: Token Introspection
7-
badge:
8-
text: v7.1
9-
variant: tip
107
redirect_from:
118
- /foss/identitymodel/endpoints/introspection/
129
---
@@ -31,16 +28,10 @@ The following code sends a reference token to an introspection endpoint:
3128
Address = Endpoint,
3229
ClientId = "client",
3330
ClientSecret = "secret",
34-
ResponseFormat = ResponseFormat.Json,
35-
36-
// Optional
37-
// JwtResponseValidator = new CustomIntrospectionJwtResponseValidator()
31+
ResponseFormat = ResponseFormat.Json
3832
};
3933
40-
var httpClient = new HttpClient()
41-
{
42-
BaseAddress = new Uri(Endpoint)
43-
};
34+
var httpClient = new HttpClient();
4435
4536
var introspectionClient = new IntrospectionClient(httpClient, clientOptions);
4637
var introspectionResponse = await introspectionClient.Introspect("token");`}
@@ -54,10 +45,7 @@ var introspectionResponse = await client.IntrospectTokenAsync(new TokenIntrospec
5445
{
5546
Address = Endpoint,
5647
Token = "token",
57-
ResponseFormat = ResponseFormat.Jwt,
58-
59-
// Optional
60-
JwtResponseValidator = new CustomIntrospectionJwtResponseValidator()
48+
ResponseFormat = ResponseFormat.Json
6149
});`}
6250
/>
6351
</TabItem>
@@ -93,12 +81,39 @@ In addition, it provides access to the following standard response parameters:
9381
| `Issuer` | The string representing the issuer of the token or `null` if the `iss` claim is missing. |
9482
| `JwtId` | The string identifier for the token or `null` if the `jti` claim is missing. |
9583

96-
## JWT Response Validation :badge[v7.1]
84+
## JWT Response Format :badge[v7.1]
85+
86+
Introspection requests can optionally pass a parameter to indicate that a signed JWT rather than JSON payload is desired.
87+
Such a JWT response is most often useful for non-repudiation. For example, an API might rely on the claims from introspection
88+
to produce digitally signed documents or issue certificates, with the Authorization Server assuming legal liability for
89+
the introspected data. A JWT introspection response can be stored and its signature independently verified as part of an audit.
9790

98-
Most applications will not benefit from additional checks at runtime. By default, no validation is performed on the
99-
incoming JWT response, it is only checked for valid JWT formatting.
91+
### Requesting JWT Response Format
10092

101-
An extensibility point is available to provide your own implementation of `ITokenIntrospectionJwtResponseValidator` using the `TokenIntrospectionRequest.JwtResponseValidator` property or using `IntrospectionClientOptions`.
93+
To request the JWT response format, set the `ResponseFormat` option to `ResponseFormat.Jwt`.
94+
95+
```csharp
96+
var client = new HttpClient();
97+
var introspectionResponse = await client.IntrospectTokenAsync(
98+
new TokenIntrospectionRequest
99+
{
100+
Address = Endpoint,
101+
Token = "token",
102+
ResponseFormat = ResponseFormat.Jwt
103+
});
104+
```
105+
106+
### Validating JWT Signature
107+
108+
By default, when the introspection endpoint returns a JWT, the system performs only a basic format check on the response.
109+
Full cryptographic validation of the JWT's signature and claims is not performed.
110+
111+
This approach is generally appropriate because the introspection request is made over a direct back-channel connection
112+
from the application to the introspection endpoint. This connection is secured by TLS, which guarantees the authenticity
113+
and integrity of the response in transit. The introspected claims can safely be used immediately without an additional
114+
cryptographic validation.
115+
116+
An extensibility point is available to provide your own implementation of `ITokenIntrospectionJwtResponseValidator`.
102117

103118
```csharp
104119
// ITokenIntrospectionJwtResponseValidator.cs
@@ -107,3 +122,18 @@ public interface ITokenIntrospectionJwtResponseValidator
107122
void Validate(string rawJwtResponse);
108123
}
109124
```
125+
126+
A custom validator can be applied using the `TokenIntrospectionRequest.JwtResponseValidator` property or using `IntrospectionClientOptions`:
127+
128+
129+
```csharp
130+
var client = new HttpClient();
131+
var introspectionResponse = await client.IntrospectTokenAsync(
132+
new TokenIntrospectionRequest
133+
{
134+
Address = Endpoint,
135+
Token = "token",
136+
ResponseFormat = ResponseFormat.Jwt,
137+
JwtResponseValidator = new CustomIntrospectionJwtResponseValidator()
138+
});
139+
```

0 commit comments

Comments
 (0)