Skip to content

Commit df2efd4

Browse files
committed
feat(runtime): upgrade project to latest .NET version
BREAKING CHANGE: dropped support for non-LTS .NET versions
1 parent 30e3630 commit df2efd4

File tree

11 files changed

+111
-74
lines changed

11 files changed

+111
-74
lines changed

.github/workflows/publish-package.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ jobs:
1616

1717
steps:
1818
- name: Checkout repository
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020

21-
- name: Setup .NET 6
22-
uses: actions/setup-dotnet@v3
21+
- name: Setup .NET 8
22+
uses: actions/setup-dotnet@v4
2323
with:
24-
dotnet-version: 6.0.x
24+
dotnet-version: 8.0.x
2525

26-
- name: Setup .NET 7
27-
uses: actions/setup-dotnet@v3
26+
- name: Setup .NET 9
27+
uses: actions/setup-dotnet@v4
2828
with:
29-
dotnet-version: 7.0.x
29+
dotnet-version: 9.0.x
3030

31-
- name: Setup .NET 8
32-
uses: actions/setup-dotnet@v3
31+
- name: Setup .NET 10
32+
uses: actions/setup-dotnet@v4
3333
with:
34-
dotnet-version: 8.0.x
34+
dotnet-version: 10.0.x
3535

3636
- name: Restore dependencies
3737
run: dotnet restore
@@ -54,4 +54,4 @@ jobs:
5454
run: dotnet pack -c Release -o out -p:PackageVersion=${{ steps.semantic.outputs.new_release_version }} -p:RepositoryUrl=${{env.CURRENT_REPO_URL}}
5555

5656
- name: Publish the package to nuget.org
57-
run: dotnet nuget push ./out/*.nupkg -n -d -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json
57+
run: dotnet nuget push ./out/*.nupkg -n -d -k ${{ secrets.NUGET_AUTH_TOKEN}} -s https://api.nuget.org/v3/index.json

.github/workflows/pull-request.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ jobs:
1313

1414
steps:
1515
- name: Checkout repository
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717

18-
- name: Setup .NET 6
19-
uses: actions/setup-dotnet@v3
18+
- name: Setup .NET 8
19+
uses: actions/setup-dotnet@v4
2020
with:
21-
dotnet-version: 6.0.x
21+
dotnet-version: 8.0.x
2222

23-
- name: Setup .NET 7
24-
uses: actions/setup-dotnet@v3
23+
- name: Setup .NET 9
24+
uses: actions/setup-dotnet@v4
2525
with:
26-
dotnet-version: 7.0.x
26+
dotnet-version: 9.0.x
2727

28-
- name: Setup .NET 8
29-
uses: actions/setup-dotnet@v3
28+
- name: Setup .NET 10
29+
uses: actions/setup-dotnet@v4
3030
with:
31-
dotnet-version: 8.0.x
31+
dotnet-version: 10.0.x
3232

3333
- name: Restore dependencies
3434
run: dotnet restore
@@ -37,4 +37,4 @@ jobs:
3737
run: dotnet build --no-restore
3838

3939
- name: Test
40-
run: dotnet test --no-build
40+
run: dotnet test --no-build

NuGet.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
5+
</packageSources>
6+
<fallbackPackageFolders>
7+
<clear />
8+
</fallbackPackageFolders>
9+
</configuration>
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
</PropertyGroup>
66

77

88
<ItemGroup>
9-
<PackageReference Include="Bogus" Version="35.5.0" />
10-
<PackageReference Include="NetDevPack.Security.Jwt.AspNetCore" Version="8.1.4" />
11-
<PackageReference Include="NetDevPack.Security.Jwt.Core" Version="8.1.4" />
12-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
9+
<PackageReference Include="Bogus" Version="35.6.5" />
10+
<PackageReference Include="NetDevPack.Security.Jwt.AspNetCore" Version="8.2.2" />
11+
<PackageReference Include="NetDevPack.Security.Jwt.Core" Version="8.2.2" />
12+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
1313
</ItemGroup>
1414

15-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
16-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.29" />
15+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
16+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
1717
</ItemGroup>
18-
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
19-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
18+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
19+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
2020
</ItemGroup>
21-
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
22-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
22+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.2" />
2323
</ItemGroup>
2424

2525
</Project>

samples/NetDevPack.Security.JwtExtensions.ApiClient/NetDevPack.Security.JwtExtensions.ApiClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
</PropertyGroup>
66

77

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.1;net8.0;net9.0;net10.0</TargetFrameworks>
55
<Version>3.1.0</Version>
66
<Authors>Bruno Brito</Authors>
77
<PackageIconUrl>https://raw.githubusercontent.com/NetDevPack/NetDevPack/master/assets/IconNuget.png</PackageIconUrl>
@@ -15,20 +15,21 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
19-
<PackageReference Include="System.Text.Json" Version="8.0.3" />
18+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
2019
</ItemGroup>
2120

2221
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
22+
<PackageReference Include="System.Text.Json" Version="10.0.2" />
2323
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.30" />
2424
</ItemGroup>
25-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
26-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.29" />
25+
26+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
27+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
2728
</ItemGroup>
28-
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
29-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
29+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
30+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
3031
</ItemGroup>
31-
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
32-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
32+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
33+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.2" />
3334
</ItemGroup>
3435
</Project>
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
55
</PropertyGroup>
66

77

@@ -10,12 +10,18 @@
1010
</ItemGroup>
1111

1212
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
13-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.29" />
13+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.35" />
1414
</ItemGroup>
1515
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
16-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
16+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.20" />
1717
</ItemGroup>
1818
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
19-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
19+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
20+
</ItemGroup>
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
22+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.12" />
23+
</ItemGroup>
24+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
25+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.2" />
2026
</ItemGroup>
2127
</Project>

tests/NetDevPack.Security.JwtExtensions.ApiTests/Startup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.DependencyInjection;
66
using Microsoft.Extensions.Hosting;
7+
using System;
78

89
namespace NetDevPack.Security.JwtExtensions.ApiTests
910
{
@@ -24,8 +25,10 @@ public void ConfigureServices(IServiceCollection services)
2425
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
2526
.AddJwtBearer(options =>
2627
{
28+
options.RequireHttpsMetadata = false;
29+
var jwksUrl = Environment.GetEnvironmentVariable("JWKS_URL") ?? "https://localhost:5001/jwks";
2730
options.IncludeErrorDetails = true; // <- great for debugging
28-
options.SetJwksOptions(new JwkOptions("https://localhost:5001/jwks", audience: "jwt-test", issuer: "https://mysite.com"));
31+
options.SetJwksOptions(new JwkOptions(jwksUrl, audience: "jwt-test", issuer: "https://mysite.com"));
2932
});
3033
}
3134

tests/NetDevPack.Security.JwtExtensions.Tests/Infra/Server.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore.Builder;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.AspNetCore.Http;
44
using Microsoft.Extensions.DependencyInjection;
55
using System;
66
using System.IO;
7+
using System.Net;
78
using System.Net.Http;
9+
using System.Net.Sockets;
810
using System.Threading.Tasks;
911

1012
namespace NetDevPack.Security.JwtExtensions.Tests.Infra
1113
{
1214
public class Server : IDisposable
1315
{
14-
public const string ServerUrl = "https://localhost:5001";
16+
public string ServerUrl { get; }
1517
public readonly IWebHost TestServer;
16-
public readonly HttpClient HttpClient = new HttpClient() { BaseAddress = new Uri(ServerUrl) };
18+
public readonly HttpClient HttpClient;
1719

1820
public Server()
1921
{
22+
var port = GetFreePort();
23+
ServerUrl = $"http://127.0.0.1:{port}";
24+
2025
TestServer =
2126
new WebHostBuilder()
2227
.UseKestrel()
@@ -35,6 +40,16 @@ public Server()
3540
.UseUrls(ServerUrl).Build();
3641
TestServer.Start();
3742

43+
HttpClient = new HttpClient { BaseAddress = new Uri(ServerUrl) };
44+
}
45+
46+
private static int GetFreePort()
47+
{
48+
var listener = new TcpListener(IPAddress.Loopback, 0);
49+
listener.Start();
50+
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
51+
listener.Stop();
52+
return port;
3853
}
3954

4055
public void Dispose()

tests/NetDevPack.Security.JwtExtensions.Tests/JwksTests.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ public JwksTests(WebApplicationFactory<Startup> webApplicationFactory, ITestOutp
2727
{
2828
_webApplicationFactory = webApplicationFactory;
2929
_output = output;
30-
_client = webApplicationFactory.CreateClient();
3130
_server = new Server();
31+
Environment.SetEnvironmentVariable("JWKS_URL", $"{_server.ServerUrl}/jwks");
32+
_client = webApplicationFactory.CreateClient(new WebApplicationFactoryClientOptions
33+
{
34+
BaseAddress = new Uri("https://localhost")
35+
});
3236
// Force key generation
33-
var tokenRequest = new HttpRequestMessage(HttpMethod.Get, "https://localhost:5001/auth");
37+
var tokenRequest = new HttpRequestMessage(HttpMethod.Get, new Uri("/auth", UriKind.Relative));
3438
_server.HttpClient.SendAsync(tokenRequest).Wait();
3539
}
3640

3741
[Fact]
3842
public async Task Should_200()
3943
{
40-
var request = new HttpRequestMessage(HttpMethod.Get, "https://localhost/WeatherForecast");
44+
var request = new HttpRequestMessage(HttpMethod.Get, "/WeatherForecast");
4145

4246
var response = await _client.SendAsync(request);
4347

@@ -47,7 +51,7 @@ public async Task Should_200()
4751
[Fact]
4852
public async Task Should_401()
4953
{
50-
var request = new HttpRequestMessage(HttpMethod.Get, "https://localhost/ProtectedWeatherForecast");
54+
var request = new HttpRequestMessage(HttpMethod.Get, "/ProtectedWeatherForecast");
5155
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "generic token");
5256
var response = await _client.SendAsync(request);
5357

@@ -57,7 +61,7 @@ public async Task Should_401()
5761
[Fact]
5862
public async Task Should_Not_Validate_Bearer_Token_With_Invalid_Signature()
5963
{
60-
var request = new HttpRequestMessage(HttpMethod.Get, "https://localhost/ProtectedWeatherForecast");
64+
var request = new HttpRequestMessage(HttpMethod.Get, "/ProtectedWeatherForecast");
6165
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", InvalidSignature);
6266
var response = await _client.SendAsync(request);
6367

@@ -67,11 +71,11 @@ public async Task Should_Not_Validate_Bearer_Token_With_Invalid_Signature()
6771
[Fact]
6872
public async Task Should_Validate_Bearer_Token()
6973
{
70-
var tokenRequest = new HttpRequestMessage(HttpMethod.Get, "https://localhost:5001/auth");
74+
var tokenRequest = new HttpRequestMessage(HttpMethod.Get, new Uri("/auth", UriKind.Relative));
7175
var tokenResponse = await _server.HttpClient.SendAsync(tokenRequest);
7276
var token = await tokenResponse.Content.ReadAsStringAsync();
7377

74-
var request = new HttpRequestMessage(HttpMethod.Get, "https://localhost/ProtectedWeatherForecast");
78+
var request = new HttpRequestMessage(HttpMethod.Get, "/ProtectedWeatherForecast");
7579
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
7680
var response = await _client.SendAsync(request);
7781

0 commit comments

Comments
 (0)