Skip to content

Commit f2b6592

Browse files
authored
Merge pull request #2 from cnblogs/replace-IdentityModel
refactor: replace IdentityModel with Duende.IdentityModel
2 parents 68b573a + 6977c7f commit f2b6592

9 files changed

+22
-20
lines changed

src/Context/SendingRequestContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
using IdentityModel.Client;
4+
using Duende.IdentityModel.Client;
55
using Microsoft.AspNetCore.Authentication;
66
using Microsoft.AspNetCore.Http;
77

src/Context/UpdateClientAssertionContext.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
using System;
5-
using IdentityModel.Client;
4+
using Duende.IdentityModel.Client;
65
using Microsoft.AspNetCore.Authentication;
76
using Microsoft.AspNetCore.Http;
7+
using System;
88

99
namespace IdentityModel.AspNetCore.OAuth2Introspection
1010
{

src/IdentityModel.AspNetCore.OAuth2Introspection.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="IdentityModel" Version="6.0.0" />
30+
<PackageReference Include="Duende.IdentityModel" Version="7.0.0" />
3131

3232
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
3333
<PackageReference Include="minver" Version="6.0.0" PrivateAssets="All" />

src/Infrastructure/CacheExtensions.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4+
using Duende.IdentityModel;
45
using Microsoft.Extensions.Caching.Distributed;
56
using Microsoft.Extensions.Logging;
67
using System;
@@ -19,20 +20,20 @@ internal static class CacheExtensions
1920
private static readonly JsonSerializerOptions Options;
2021

2122
static CacheExtensions()
22-
{
23+
{
2324
Options = new JsonSerializerOptions
2425
{
2526
IgnoreReadOnlyFields = true,
2627
IgnoreReadOnlyProperties = true,
2728
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
2829
};
29-
30+
3031
Options.Converters.Add(new ClaimConverter());
3132
}
3233

3334
public static async Task<IEnumerable<Claim>> GetClaimsAsync(this IDistributedCache cache, OAuth2IntrospectionOptions options, string token)
3435
{
35-
var cacheKey = options.CacheKeyGenerator(options,token);
36+
var cacheKey = options.CacheKeyGenerator(options, token);
3637
var bytes = await cache.GetAsync(cacheKey).ConfigureAwait(false);
3738

3839
if (bytes == null)

src/OAuth2IntrospectionHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
using IdentityModel.Client;
4+
using Duende.IdentityModel.Client;
55
using Microsoft.AspNetCore.Authentication;
66
using Microsoft.AspNetCore.Http;
77
using Microsoft.Extensions.Caching.Distributed;

src/OAuth2IntrospectionOptions.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4+
using Duende.IdentityModel;
5+
using Duende.IdentityModel.Client;
46
using IdentityModel.AspNetCore.OAuth2Introspection.Infrastructure;
5-
using IdentityModel.Client;
67
using Microsoft.AspNetCore.Authentication;
78
using Microsoft.AspNetCore.Http;
89
using System;
@@ -116,7 +117,7 @@ public OAuth2IntrospectionOptions()
116117
/// <summary>
117118
/// Specifies the method how to generate the cache key from the token
118119
/// </summary>
119-
public Func<OAuth2IntrospectionOptions,string, string> CacheKeyGenerator { get; set; } = CacheUtils.CacheKeyFromToken();
120+
public Func<OAuth2IntrospectionOptions, string, string> CacheKeyGenerator { get; set; } = CacheUtils.CacheKeyFromToken();
120121

121122
/// <summary>
122123
/// Specifies the method how to retrieve the token from the HTTP request
@@ -133,7 +134,7 @@ public OAuth2IntrospectionOptions()
133134
}
134135

135136
internal AsyncLazy<HttpClient> IntrospectionClient { get; set; }
136-
137+
137138
/// <summary>
138139
/// Check that the options are valid. Should throw an exception if things are not ok.
139140
/// </summary>

src/PostConfigureOAuth2IntrospectionOptions.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
using System;
5-
using System.Net.Http;
6-
using System.Threading.Tasks;
4+
using Duende.IdentityModel.Client;
75
using IdentityModel.AspNetCore.OAuth2Introspection.Infrastructure;
8-
using IdentityModel.Client;
96
using Microsoft.Extensions.Caching.Distributed;
107
using Microsoft.Extensions.Options;
8+
using System;
9+
using System.Net.Http;
10+
using System.Threading.Tasks;
1111

1212
namespace IdentityModel.AspNetCore.OAuth2Introspection
1313
{
@@ -30,7 +30,7 @@ public void PostConfigure(string name, OAuth2IntrospectionOptions options)
3030
{
3131
throw new ArgumentException("Caching is enabled, but no IDistributedCache is found in the services collection", nameof(_cache));
3232
}
33-
33+
3434
options.IntrospectionClient = new AsyncLazy<HttpClient>(() => InitializeIntrospectionClient(options));
3535
}
3636

@@ -53,7 +53,7 @@ private async Task<string> GetIntrospectionEndpointFromDiscoveryDocument(OAuth2I
5353
Address = options.Authority,
5454
Policy = options?.DiscoveryPolicy ?? new DiscoveryPolicy()
5555
}).ConfigureAwait(false);
56-
56+
5757
if (disco.IsError)
5858
{
5959
switch (disco.ErrorType)

test/Tests/Configuration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4+
using Duende.IdentityModel.Client;
45
using FluentAssertions;
56
using IdentityModel.AspNetCore.OAuth2Introspection;
6-
using IdentityModel.Client;
77
using System;
88
using System.Threading.Tasks;
99
using Tests.Util;

test/Tests/Introspection.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4+
using Duende.IdentityModel;
5+
using Duende.IdentityModel.Client;
46
using FluentAssertions;
5-
using IdentityModel;
67
using IdentityModel.AspNetCore.OAuth2Introspection;
7-
using IdentityModel.Client;
88
using Microsoft.AspNetCore.TestHost;
99
using Microsoft.Extensions.Caching.Distributed;
1010
using Microsoft.Extensions.DependencyInjection;

0 commit comments

Comments
 (0)