Skip to content

Commit 68b573a

Browse files
authored
Merge pull request #1 from cnblogs/update-to-net9
chore(deps): update to .net 9
2 parents c526a3a + 5639165 commit 68b573a

File tree

8 files changed

+53
-65
lines changed

8 files changed

+53
-65
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
uses: actions/setup-dotnet@v2
2626
with:
2727
dotnet-version: |
28-
6.0.x
29-
7.0.x
28+
9.0.x
3029
3130
- run: dotnet --info
3231

@@ -38,5 +37,4 @@ jobs:
3837
env:
3938
SignClientSecret: ${{ secrets.SIGNCLIENTSECRET }}
4039
run: |
41-
./build.cmd sign
42-
dotnet nuget push .\artifacts\*.nupkg -s https://www.myget.org/F/identity/api/v2/package -k ${{ secrets.MYGET }}
40+
./build.cmd sign

build/Program.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Threading.Tasks;
34
using static Bullseye.Targets;
45
using static SimpleExec.Command;
56

@@ -22,7 +23,7 @@ private static class Targets
2223
public const string SignPackage = "sign-package";
2324
}
2425

25-
internal static void Main(string[] args)
26+
internal static async Task Main(string[] args)
2627
{
2728
Target(Targets.RestoreTools, () =>
2829
{
@@ -34,12 +35,12 @@ internal static void Main(string[] args)
3435
Run("dotnet", "clean -c Release -v m --nologo");
3536
});
3637

37-
Target(Targets.Build, DependsOn(Targets.CleanBuildOutput), () =>
38+
Target(Targets.Build, dependsOn: [Targets.CleanBuildOutput], () =>
3839
{
3940
Run("dotnet", "build -c Release --nologo");
4041
});
4142

42-
Target(Targets.Test, DependsOn(Targets.Build), () =>
43+
Target(Targets.Test, dependsOn: [Targets.Build], () =>
4344
{
4445
Run("dotnet", "test -c Release --no-build --nologo");
4546
});
@@ -52,21 +53,21 @@ internal static void Main(string[] args)
5253
}
5354
});
5455

55-
Target(Targets.Pack, DependsOn(Targets.Build, Targets.CleanPackOutput), () =>
56+
Target(Targets.Pack, dependsOn: [Targets.Build, Targets.CleanPackOutput], () =>
5657
{
5758
Run("dotnet", $"pack ./src/IdentityModel.AspNetCore.OAuth2Introspection.csproj -c Release -o {Directory.CreateDirectory(packOutput).FullName} --no-build --nologo");
5859
});
5960

60-
Target(Targets.SignPackage, DependsOn(Targets.Pack, Targets.RestoreTools), () =>
61+
Target(Targets.SignPackage, dependsOn: [Targets.Pack, Targets.RestoreTools], () =>
6162
{
6263
SignNuGet();
6364
});
6465

65-
Target("default", DependsOn(Targets.Test, Targets.Pack));
66+
Target("default", dependsOn: [Targets.Test, Targets.Pack]);
6667

67-
Target("sign", DependsOn(Targets.Test, Targets.SignPackage));
68+
Target("sign", dependsOn: [Targets.Test, Targets.SignPackage]);
6869

69-
RunTargetsAndExit(args, ex => ex is SimpleExec.NonZeroExitCodeException || ex.Message.EndsWith(envVarMissing));
70+
await RunTargetsAndExitAsync(args, ex => ex is SimpleExec.ExitCodeException || ex.Message.EndsWith(envVarMissing));
7071
}
7172

7273
private static void SignNuGet()
@@ -92,7 +93,7 @@ private static void SignNuGet()
9293
"--azure-key-vault-tenant-id ed3089f0-5401-4758-90eb-066124e2d907 " +
9394
$"--azure-key-vault-client-secret {signClientSecret} " +
9495
"--azure-key-vault-certificate CodeSigning"
95-
,noEcho: true);
96+
, noEcho: true);
9697
}
9798
}
9899
}

build/build.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Bullseye" Version="3.3.0" />
10-
<PackageReference Include="SimpleExec" Version="6.2.0" />
9+
<PackageReference Include="Bullseye" Version="6.0.0" />
10+
<PackageReference Include="SimpleExec" Version="12.0.0" />
1111
</ItemGroup>
12-
12+
1313
</Project>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.100",
3+
"version": "9.0.203",
44
"rollForward": "latestMajor",
55
"allowPrerelease": false
66
}

src/IdentityModel.AspNetCore.OAuth2Introspection.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
44

55
<PackageId>IdentityModel.AspNetCore.OAuth2Introspection</PackageId>
66
<Description>ASP.NET Core authentication handler for validating tokens using OAuth 2.0 introspection</Description>
@@ -11,7 +11,7 @@
1111
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1212
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1313
</PropertyGroup>
14-
14+
1515
<PropertyGroup>
1616
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1717
<EmbedUntrackedSources>true</EmbedUntrackedSources>
@@ -29,7 +29,7 @@
2929
<ItemGroup>
3030
<PackageReference Include="IdentityModel" Version="6.0.0" />
3131

32-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
33-
<PackageReference Include="minver" Version="4.3.0" PrivateAssets="All" />
32+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
33+
<PackageReference Include="minver" Version="6.0.0" PrivateAssets="All" />
3434
</ItemGroup>
3535
</Project>

src/OAuth2IntrospectionHandler.cs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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;
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;
410
using System;
511
using System.Collections.Concurrent;
612
using System.Collections.Generic;
713
using System.Linq;
814
using System.Security.Claims;
915
using System.Text.Encodings.Web;
1016
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;
1717

1818
namespace IdentityModel.AspNetCore.OAuth2Introspection
1919
{
@@ -33,16 +33,14 @@ public class OAuth2IntrospectionHandler : AuthenticationHandler<OAuth2Introspect
3333
/// </summary>
3434
/// <param name="options">The options.</param>
3535
/// <param name="urlEncoder">The URL encoder.</param>
36-
/// <param name="clock">The clock.</param>
3736
/// <param name="loggerFactory">The logger factory.</param>
3837
/// <param name="cache">The cache.</param>
3938
public OAuth2IntrospectionHandler(
4039
IOptionsMonitor<OAuth2IntrospectionOptions> options,
4140
UrlEncoder urlEncoder,
42-
ISystemClock clock,
4341
ILoggerFactory loggerFactory,
4442
IDistributedCache cache = null)
45-
: base(options, loggerFactory, urlEncoder, clock)
43+
: base(options, loggerFactory, urlEncoder)
4644
{
4745
_logger = loggerFactory.CreateLogger<OAuth2IntrospectionHandler>();
4846
_cache = cache;
@@ -154,10 +152,10 @@ await _cache.SetClaimsAsync(Options, token, claimsWithExp, Options.CacheDuration
154152
}
155153

156154
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,
161159
OAuth2IntrospectionOptions options)
162160
{
163161
var authenticationFailedContext = new AuthenticationFailedContext(httpContext, scheme, options)
@@ -171,11 +169,11 @@ private static async Task<AuthenticateResult> ReportNonSuccessAndReturn(
171169
}
172170

173171
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)
179177
{
180178
var introspectionClient = await options.IntrospectionClient.Value.ConfigureAwait(false);
181179
using var request = CreateTokenIntrospectionRequest(token, context, scheme, events, options);
@@ -191,10 +189,10 @@ private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
191189
}
192190

193191
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,
198196
OAuth2IntrospectionOptions options)
199197
{
200198
if (options.ClientSecret == null && options.ClientAssertionExpirationTime <= DateTime.UtcNow)
@@ -231,10 +229,10 @@ private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
231229
}
232230

233231
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,
238236
OAuth2IntrospectionEvents events,
239237
OAuth2IntrospectionOptions options)
240238
{

test/Tests/Introspection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace Tests
2020
{
2121
public class Introspection
2222
{
23-
2423
private static readonly string clientId = "client";
2524
private static readonly string clientSecret = "secret";
2625

test/Tests/Tests.csproj

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
2+
33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\..\src\IdentityModel.AspNetCore.OAuth2Introspection.csproj" />
99
</ItemGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
1414
<PrivateAssets>all</PrivateAssets>
1515
</PackageReference>
16-
<PackageReference Include="xunit" Version="2.4.1" />
16+
<PackageReference Include="xunit" Version="2.9.3" />
1717
<PackageReference Include="FluentAssertions" Version="5.10.3" />
18-
19-
20-
</ItemGroup>
21-
22-
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
23-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
24-
</ItemGroup>
18+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.4" />
2519

26-
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
27-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.0" />
2820
</ItemGroup>
29-
30-
21+
22+
3123
</Project>

0 commit comments

Comments
 (0)