1
1
// Copyright (c) Duende Software. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3
3
4
+ using IdentityModel . Client ;
5
+ using Microsoft . AspNetCore . Authentication ;
6
+ using Microsoft . AspNetCore . Http ;
7
+ using Microsoft . Extensions . Caching . Distributed ;
8
+ using Microsoft . Extensions . Logging ;
9
+ using Microsoft . Extensions . Options ;
4
10
using System ;
5
11
using System . Collections . Concurrent ;
6
12
using System . Collections . Generic ;
7
13
using System . Linq ;
8
14
using System . Security . Claims ;
9
15
using System . Text . Encodings . Web ;
10
16
using System . Threading . Tasks ;
11
- using IdentityModel . Client ;
12
- using Microsoft . AspNetCore . Authentication ;
13
- using Microsoft . AspNetCore . Http ;
14
- using Microsoft . Extensions . Caching . Distributed ;
15
- using Microsoft . Extensions . Logging ;
16
- using Microsoft . Extensions . Options ;
17
17
18
18
namespace IdentityModel . AspNetCore . OAuth2Introspection
19
19
{
@@ -33,16 +33,14 @@ public class OAuth2IntrospectionHandler : AuthenticationHandler<OAuth2Introspect
33
33
/// </summary>
34
34
/// <param name="options">The options.</param>
35
35
/// <param name="urlEncoder">The URL encoder.</param>
36
- /// <param name="clock">The clock.</param>
37
36
/// <param name="loggerFactory">The logger factory.</param>
38
37
/// <param name="cache">The cache.</param>
39
38
public OAuth2IntrospectionHandler (
40
39
IOptionsMonitor < OAuth2IntrospectionOptions > options ,
41
40
UrlEncoder urlEncoder ,
42
- ISystemClock clock ,
43
41
ILoggerFactory loggerFactory ,
44
42
IDistributedCache cache = null )
45
- : base ( options , loggerFactory , urlEncoder , clock )
43
+ : base ( options , loggerFactory , urlEncoder )
46
44
{
47
45
_logger = loggerFactory . CreateLogger < OAuth2IntrospectionHandler > ( ) ;
48
46
_cache = cache ;
@@ -154,10 +152,10 @@ await _cache.SetClaimsAsync(Options, token, claimsWithExp, Options.CacheDuration
154
152
}
155
153
156
154
private static async Task < AuthenticateResult > ReportNonSuccessAndReturn (
157
- string error ,
158
- HttpContext httpContext ,
159
- AuthenticationScheme scheme ,
160
- OAuth2IntrospectionEvents events ,
155
+ string error ,
156
+ HttpContext httpContext ,
157
+ AuthenticationScheme scheme ,
158
+ OAuth2IntrospectionEvents events ,
161
159
OAuth2IntrospectionOptions options )
162
160
{
163
161
var authenticationFailedContext = new AuthenticationFailedContext ( httpContext , scheme , options )
@@ -171,11 +169,11 @@ private static async Task<AuthenticateResult> ReportNonSuccessAndReturn(
171
169
}
172
170
173
171
private static async Task < TokenIntrospectionResponse > LoadClaimsForToken (
174
- string token ,
175
- HttpContext context ,
176
- AuthenticationScheme scheme ,
177
- OAuth2IntrospectionEvents events ,
178
- OAuth2IntrospectionOptions options )
172
+ string token ,
173
+ HttpContext context ,
174
+ AuthenticationScheme scheme ,
175
+ OAuth2IntrospectionEvents events ,
176
+ OAuth2IntrospectionOptions options )
179
177
{
180
178
var introspectionClient = await options . IntrospectionClient . Value . ConfigureAwait ( false ) ;
181
179
using var request = CreateTokenIntrospectionRequest ( token , context , scheme , events , options ) ;
@@ -191,10 +189,10 @@ private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
191
189
}
192
190
193
191
private static TokenIntrospectionRequest CreateTokenIntrospectionRequest (
194
- string token ,
195
- HttpContext context ,
196
- AuthenticationScheme scheme ,
197
- OAuth2IntrospectionEvents events ,
192
+ string token ,
193
+ HttpContext context ,
194
+ AuthenticationScheme scheme ,
195
+ OAuth2IntrospectionEvents events ,
198
196
OAuth2IntrospectionOptions options )
199
197
{
200
198
if ( options . ClientSecret == null && options . ClientAssertionExpirationTime <= DateTime . UtcNow )
@@ -231,10 +229,10 @@ private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
231
229
}
232
230
233
231
private static async Task < AuthenticateResult > CreateTicket (
234
- IEnumerable < Claim > claims ,
235
- string token ,
236
- HttpContext httpContext ,
237
- AuthenticationScheme scheme ,
232
+ IEnumerable < Claim > claims ,
233
+ string token ,
234
+ HttpContext httpContext ,
235
+ AuthenticationScheme scheme ,
238
236
OAuth2IntrospectionEvents events ,
239
237
OAuth2IntrospectionOptions options )
240
238
{
0 commit comments