Skip to content

chore(deps): update to .net 9 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
7.0.x
9.0.x

- run: dotnet --info

Expand All @@ -38,5 +37,4 @@ jobs:
env:
SignClientSecret: ${{ secrets.SIGNCLIENTSECRET }}
run: |
./build.cmd sign
dotnet nuget push .\artifacts\*.nupkg -s https://www.myget.org/F/identity/api/v2/package -k ${{ secrets.MYGET }}
./build.cmd sign
19 changes: 10 additions & 9 deletions build/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Threading.Tasks;
using static Bullseye.Targets;
using static SimpleExec.Command;

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

internal static void Main(string[] args)
internal static async Task Main(string[] args)
{
Target(Targets.RestoreTools, () =>
{
Expand All @@ -34,12 +35,12 @@ internal static void Main(string[] args)
Run("dotnet", "clean -c Release -v m --nologo");
});

Target(Targets.Build, DependsOn(Targets.CleanBuildOutput), () =>
Target(Targets.Build, dependsOn: [Targets.CleanBuildOutput], () =>
{
Run("dotnet", "build -c Release --nologo");
});

Target(Targets.Test, DependsOn(Targets.Build), () =>
Target(Targets.Test, dependsOn: [Targets.Build], () =>
{
Run("dotnet", "test -c Release --no-build --nologo");
});
Expand All @@ -52,21 +53,21 @@ internal static void Main(string[] args)
}
});

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

Target(Targets.SignPackage, DependsOn(Targets.Pack, Targets.RestoreTools), () =>
Target(Targets.SignPackage, dependsOn: [Targets.Pack, Targets.RestoreTools], () =>
{
SignNuGet();
});

Target("default", DependsOn(Targets.Test, Targets.Pack));
Target("default", dependsOn: [Targets.Test, Targets.Pack]);

Target("sign", DependsOn(Targets.Test, Targets.SignPackage));
Target("sign", dependsOn: [Targets.Test, Targets.SignPackage]);

RunTargetsAndExit(args, ex => ex is SimpleExec.NonZeroExitCodeException || ex.Message.EndsWith(envVarMissing));
await RunTargetsAndExitAsync(args, ex => ex is SimpleExec.ExitCodeException || ex.Message.EndsWith(envVarMissing));
}

private static void SignNuGet()
Expand All @@ -92,7 +93,7 @@ private static void SignNuGet()
"--azure-key-vault-tenant-id ed3089f0-5401-4758-90eb-066124e2d907 " +
$"--azure-key-vault-client-secret {signClientSecret} " +
"--azure-key-vault-certificate CodeSigning"
,noEcho: true);
, noEcho: true);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bullseye" Version="3.3.0" />
<PackageReference Include="SimpleExec" Version="6.2.0" />
<PackageReference Include="Bullseye" Version="6.0.0" />
<PackageReference Include="SimpleExec" Version="12.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "9.0.203",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
8 changes: 4 additions & 4 deletions src/IdentityModel.AspNetCore.OAuth2Introspection.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>

<PackageId>IdentityModel.AspNetCore.OAuth2Introspection</PackageId>
<Description>ASP.NET Core authentication handler for validating tokens using OAuth 2.0 introspection</Description>
Expand All @@ -11,7 +11,7 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand All @@ -29,7 +29,7 @@
<ItemGroup>
<PackageReference Include="IdentityModel" Version="6.0.0" />

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="minver" Version="4.3.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="minver" Version="6.0.0" PrivateAssets="All" />
</ItemGroup>
</Project>
50 changes: 24 additions & 26 deletions src/OAuth2IntrospectionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (c) Duende Software. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

using IdentityModel.Client;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using IdentityModel.Client;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace IdentityModel.AspNetCore.OAuth2Introspection
{
Expand All @@ -33,16 +33,14 @@ public class OAuth2IntrospectionHandler : AuthenticationHandler<OAuth2Introspect
/// </summary>
/// <param name="options">The options.</param>
/// <param name="urlEncoder">The URL encoder.</param>
/// <param name="clock">The clock.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="cache">The cache.</param>
public OAuth2IntrospectionHandler(
IOptionsMonitor<OAuth2IntrospectionOptions> options,
UrlEncoder urlEncoder,
ISystemClock clock,
ILoggerFactory loggerFactory,
IDistributedCache cache = null)
: base(options, loggerFactory, urlEncoder, clock)
: base(options, loggerFactory, urlEncoder)
{
_logger = loggerFactory.CreateLogger<OAuth2IntrospectionHandler>();
_cache = cache;
Expand Down Expand Up @@ -154,10 +152,10 @@ await _cache.SetClaimsAsync(Options, token, claimsWithExp, Options.CacheDuration
}

private static async Task<AuthenticateResult> ReportNonSuccessAndReturn(
string error,
HttpContext httpContext,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
string error,
HttpContext httpContext,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
OAuth2IntrospectionOptions options)
{
var authenticationFailedContext = new AuthenticationFailedContext(httpContext, scheme, options)
Expand All @@ -171,11 +169,11 @@ private static async Task<AuthenticateResult> ReportNonSuccessAndReturn(
}

private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
string token,
HttpContext context,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
OAuth2IntrospectionOptions options)
string token,
HttpContext context,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
OAuth2IntrospectionOptions options)
{
var introspectionClient = await options.IntrospectionClient.Value.ConfigureAwait(false);
using var request = CreateTokenIntrospectionRequest(token, context, scheme, events, options);
Expand All @@ -191,10 +189,10 @@ private static async Task<TokenIntrospectionResponse> LoadClaimsForToken(
}

private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
string token,
HttpContext context,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
string token,
HttpContext context,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
OAuth2IntrospectionOptions options)
{
if (options.ClientSecret == null && options.ClientAssertionExpirationTime <= DateTime.UtcNow)
Expand Down Expand Up @@ -231,10 +229,10 @@ private static TokenIntrospectionRequest CreateTokenIntrospectionRequest(
}

private static async Task<AuthenticateResult> CreateTicket(
IEnumerable<Claim> claims,
string token,
HttpContext httpContext,
AuthenticationScheme scheme,
IEnumerable<Claim> claims,
string token,
HttpContext httpContext,
AuthenticationScheme scheme,
OAuth2IntrospectionEvents events,
OAuth2IntrospectionOptions options)
{
Expand Down
1 change: 0 additions & 1 deletion test/Tests/Introspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace Tests
{
public class Introspection
{

private static readonly string clientId = "client";
private static readonly string clientSecret = "secret";

Expand Down
24 changes: 8 additions & 16 deletions test/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\IdentityModel.AspNetCore.OAuth2Introspection.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />


</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0" />
</ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.4" />

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.0" />
</ItemGroup>


</Project>