@@ -178,7 +178,7 @@ private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
178
178
OAuth2IntrospectionOptions options )
179
179
{
180
180
var introspectionClient = await options . IntrospectionClient . Value . ConfigureAwait ( false ) ;
181
- using var request = CreateTokenIntrospectionRequest ( token , context , scheme , events , options ) ;
181
+ using var request = await CreateTokenIntrospectionRequest ( token , context , scheme , events , options ) ;
182
182
183
183
var requestSendingContext = new SendingRequestContext ( context , scheme , options )
184
184
{
@@ -190,7 +190,7 @@ private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
190
190
return await introspectionClient . IntrospectTokenAsync ( request ) . ConfigureAwait ( false ) ;
191
191
}
192
192
193
- private static TokenIntrospectionRequest CreateTokenIntrospectionRequest (
193
+ private static async ValueTask < TokenIntrospectionRequest > CreateTokenIntrospectionRequest (
194
194
string token ,
195
195
HttpContext context ,
196
196
AuthenticationScheme scheme ,
@@ -199,7 +199,9 @@ private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
199
199
{
200
200
if ( options . ClientSecret == null && options . ClientAssertionExpirationTime <= DateTime . UtcNow )
201
201
{
202
- lock ( options . AssertionUpdateLockObj )
202
+ await options . AssertionUpdateLock . WaitAsync ( ) ;
203
+
204
+ try
203
205
{
204
206
if ( options . ClientAssertionExpirationTime <= DateTime . UtcNow )
205
207
{
@@ -208,13 +210,17 @@ private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
208
210
ClientAssertion = options . ClientAssertion ?? new ClientAssertion ( )
209
211
} ;
210
212
211
- events . UpdateClientAssertion ( updateClientAssertionContext ) ;
213
+ await events . UpdateClientAssertion ( updateClientAssertionContext ) ;
212
214
213
215
options . ClientAssertion = updateClientAssertionContext . ClientAssertion ;
214
216
options . ClientAssertionExpirationTime =
215
217
updateClientAssertionContext . ClientAssertionExpirationTime ;
216
218
}
217
219
}
220
+ finally
221
+ {
222
+ options . AssertionUpdateLock . Release ( ) ;
223
+ }
218
224
}
219
225
220
226
return new TokenIntrospectionRequest
0 commit comments