Skip to content

Commit d63f6a7

Browse files
authored
Update to .NET 9 (#4)
1 parent fe637e8 commit d63f6a7

File tree

280 files changed

+1105
-1185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+1105
-1185
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v3
2626
- name: Setup .NET
27-
uses: actions/setup-dotnet@v2
27+
uses: actions/setup-dotnet@v4
2828
with:
29-
dotnet-version: 7.0.x
29+
dotnet-version: '9'
3030
- if: contains(matrix.runs-on, 'macOS') || contains(matrix.runs-on, 'ubuntu')
3131
env:
3232
MINVERVERSIONOVERRIDE: ${{ secrets.MINVER_VERSION }}

global.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.100"
3+
"version": "9.0.203",
4+
"rollForward": "latestFeature"
45
}
56
}
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<AspNetVersion>3.1.0</AspNetVersion>
5-
</PropertyGroup>
3+
<PropertyGroup>
4+
<AspNetVersion>9.0.4</AspNetVersion>
5+
</PropertyGroup>
66

7-
<ItemGroup>
8-
<PackageReference Update="IdentityModel" Version="4.3.0" />
9-
10-
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(AspNetVersion)" />
11-
<PackageReference Update="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetVersion)" />
12-
<PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetVersion)" />
13-
<PackageReference Update="Microsoft.AspNetCore.Authentication.Certificate" Version="$(AspNetVersion)"/>
14-
15-
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
16-
</ItemGroup>
7+
<ItemGroup>
8+
<PackageReference Update="Duende.IdentityModel" Version="7.0.0" />
9+
10+
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(AspNetVersion)" />
11+
<PackageReference Update="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetVersion)" />
12+
<PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetVersion)" />
13+
<PackageReference Update="Microsoft.AspNetCore.Authentication.Certificate" Version="$(AspNetVersion)" />
14+
15+
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
16+
</ItemGroup>
1717
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
9-
9+
1010
<ProjectReference Include="..\Constants\Constants.csproj" />
1111
</ItemGroup>
1212
</Project>

samples/Clients/old/MvcHybrid/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.AspNetCore.Builder;
33
using Microsoft.Extensions.DependencyInjection;
44
using System.IdentityModel.Tokens.Jwt;
5-
using IdentityModel;
5+
using Duende.IdentityModel;
66
using Clients;
77
using Microsoft.IdentityModel.Tokens;
88
using Microsoft.AspNetCore.Authentication.Cookies;

samples/Clients/old/MvcHybridAutomaticRefresh/MvcHybridAutomaticRefresh.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

samples/Clients/old/MvcHybridAutomaticRefresh/Startup.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.AspNetCore.Builder;
33
using Microsoft.Extensions.DependencyInjection;
44
using System.IdentityModel.Tokens.Jwt;
5-
using IdentityModel;
5+
using Duende.IdentityModel;
66
using Clients;
77
using Microsoft.IdentityModel.Tokens;
88
using Microsoft.AspNetCore.Authentication.Cookies;
@@ -50,7 +50,7 @@ public void ConfigureServices(IServiceCollection services)
5050
options.Scope.Add("email");
5151
options.Scope.Add("api1");
5252
options.Scope.Add("offline_access");
53-
53+
5454
options.ClaimActions.MapAllExcept("iss", "nbf", "exp", "aud", "nonce", "iat", "c_hash");
5555

5656
options.GetClaimsFromUserInfoEndpoint = true;

samples/Clients/old/MvcImplicit/MvcImplicit.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

samples/Clients/old/MvcImplicit/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Clients;
2-
using IdentityModel;
2+
using Duende.IdentityModel;
33
using Microsoft.AspNetCore.Authentication.Cookies;
44
using Microsoft.AspNetCore.Builder;
55
using Microsoft.Extensions.DependencyInjection;

samples/Clients/old/MvcImplicitJwtRequest/MvcImplicitJwtRequest.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
9-
9+
1010
<ProjectReference Include="..\Constants\Constants.csproj" />
1111
</ItemGroup>
1212

samples/Clients/old/MvcImplicitJwtRequest/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Clients;
2-
using IdentityModel;
2+
using Duende.IdentityModel;
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.IdentityModel.Tokens;

samples/Clients/old/MvcManual/Controllers/HomeController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Linq;
77
using Microsoft.IdentityModel.Tokens;
88
using System.Collections.Generic;
9-
using IdentityModel;
9+
using Duende.IdentityModel;
1010
using System.Security.Cryptography;
1111
using System.IdentityModel.Tokens.Jwt;
1212
using Clients;
@@ -32,7 +32,7 @@ public async Task<IActionResult> Secure()
3232
return await StartAuthentication();
3333
}
3434

35-
public async Task <IActionResult> Logout()
35+
public async Task<IActionResult> Logout()
3636
{
3737
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
3838

samples/Clients/old/MvcManual/MvcManual.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
15-
15+
1616
<ProjectReference Include="..\Constants\Constants.csproj" />
1717
</ItemGroup>
1818

@@ -25,4 +25,4 @@
2525
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
2626
</ItemGroup>
2727

28-
</Project>
28+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using Microsoft.AspNetCore;
31
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
43
using Serilog;
54
using Serilog.Events;
65
using Serilog.Sinks.SystemConsole.Themes;
6+
using System;
77

88
namespace ResourceBasedApi
99
{
@@ -13,10 +13,10 @@ public static void Main(string[] args)
1313
{
1414
Console.Title = "Sample API";
1515

16-
BuildWebHost(args).Run();
16+
CreateHostBuilder(args).Build().Run();
1717
}
1818

19-
public static IWebHost BuildWebHost(string[] args)
19+
public static IHostBuilder CreateHostBuilder(string[] args)
2020
{
2121
Log.Logger = new LoggerConfiguration()
2222
.MinimumLevel.Verbose()
@@ -27,10 +27,12 @@ public static IWebHost BuildWebHost(string[] args)
2727
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
2828
.CreateLogger();
2929

30-
return WebHost.CreateDefaultBuilder(args)
31-
.UseStartup<Startup>()
32-
.UseSerilog()
33-
.Build();
30+
return Host.CreateDefaultBuilder(args)
31+
.UseSerilog()
32+
.ConfigureWebHostDefaults(webBuilder =>
33+
{
34+
webBuilder.UseStartup<Startup>();
35+
});
3436
}
3537
}
3638
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\..\Constants\Constants.csproj" />
99
</ItemGroup>
10-
10+
1111
<ItemGroup>
12-
<PackageReference Include="IdentityModel.AspNetCore.AccessTokenValidation" Version="1.0.0-preview.3" />
13-
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="4.0.1" />
14-
15-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
16-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
17-
18-
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
12+
<PackageReference Include="Cnblogs.IdentityServer4.AccessTokenValidation" Version="3.1.0" />
13+
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
15+
16+
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
1917
</ItemGroup>
2018

2119
</Project>

samples/Clients/src/APIs/ResourceBasedApi/Startup.cs

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
using Clients;
1+
using Clients;
22
using Microsoft.AspNetCore.Builder;
33
using Microsoft.Extensions.DependencyInjection;
4-
using System;
5-
using System.IdentityModel.Tokens.Jwt;
6-
using System.Security.Cryptography.X509Certificates;
7-
using System.Text;
8-
using System.Threading.Tasks;
9-
using IdentityModel.AspNetCore.AccessTokenValidation;
10-
using Microsoft.AspNetCore.Http;
11-
using Microsoft.AspNetCore.HttpOverrides;
124

135
namespace ResourceBasedApi
146
{
@@ -32,7 +24,7 @@ public void ConfigureServices(IServiceCollection services)
3224
options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" };
3325

3426
// if token does not contain a dot, it is a reference token
35-
options.ForwardDefaultSelector = Selector.ForwardReferenceToken("introspection");
27+
// options.ForwardDefaultSelector = Selector.ForwardReferenceToken("introspection");
3628
})
3729

3830
// reference tokens
@@ -44,7 +36,7 @@ public void ConfigureServices(IServiceCollection services)
4436
options.ClientSecret = "secret";
4537
});
4638

47-
services.AddScopeTransformation();
39+
// services.AddScopeTransformation();
4840
}
4941

5042
public void Configure(IApplicationBuilder app)
+10-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using Microsoft.AspNetCore;
31
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
43
using Serilog;
54
using Serilog.Events;
65
using Serilog.Sinks.SystemConsole.Themes;
6+
using System;
77

88
namespace SampleApi
99
{
@@ -13,10 +13,10 @@ public static void Main(string[] args)
1313
{
1414
Console.Title = "Sample API";
1515

16-
BuildWebHost(args).Run();
16+
CreateHostBuilder(args).Build().Run();
1717
}
1818

19-
public static IWebHost BuildWebHost(string[] args)
19+
public static IHostBuilder CreateHostBuilder(string[] args)
2020
{
2121
Log.Logger = new LoggerConfiguration()
2222
.MinimumLevel.Verbose()
@@ -27,10 +27,12 @@ public static IWebHost BuildWebHost(string[] args)
2727
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code)
2828
.CreateLogger();
2929

30-
return WebHost.CreateDefaultBuilder(args)
31-
.UseStartup<Startup>()
32-
.UseSerilog()
33-
.Build();
30+
return Host.CreateDefaultBuilder(args)
31+
.UseSerilog()
32+
.ConfigureWebHostDefaults(webBuilder =>
33+
{
34+
webBuilder.UseStartup<Startup>();
35+
});
3436
}
3537
}
3638
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\..\Constants\Constants.csproj" />
99
</ItemGroup>
10-
10+
1111
<ItemGroup>
12-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" />
13-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
14-
15-
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
12+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
13+
14+
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
1615
</ItemGroup>
1716

1817
</Project>

samples/Clients/src/ConsoleClientCredentialsFlow/ConsoleClientCredentialsFlow.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

samples/Clients/src/ConsoleClientCredentialsFlow/Program.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using Clients;
2-
using IdentityModel.Client;
3-
using Newtonsoft.Json.Linq;
1+
using Clients;
2+
using Duende.IdentityModel.Client;
43
using System;
54
using System.Net.Http;
65
using System.Threading.Tasks;
@@ -52,7 +51,7 @@ static async Task CallServiceAsync(string token)
5251
var response = await client.GetStringAsync("identity");
5352

5453
"\n\nService claims:".ConsoleGreen();
55-
Console.WriteLine(JArray.Parse(response));
54+
Console.WriteLine(response);
5655
}
5756
}
5857
}

samples/Clients/src/ConsoleClientCredentialsFlowCallingIdentityServerApi/ConsoleClientCredentialsFlowCallingIdentityServerApi.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

0 commit comments

Comments
 (0)