Skip to content
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

v5.0.0 #30

Merged
merged 4 commits into from
Jan 30, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This library hopes to solve that problem, featuring:

:white_check_mark: `IHttpClientBuilder` extensions, providing handlers to automatically append access tokens to outgoing requests.

This library is compatible with all .NET Standard 2.0 runtimes (.NET 8+ recommended) and is suitable for use in ASP.NET Core and standalone .NET Generic Host applications.
This library is compatible with .NET 8+ as well as .NET Framework 4.8 and is suitable for use in ASP.NET Core and standalone .NET Generic Host applications.

## Install

Expand Down
1 change: 0 additions & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;

Expand Down
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="8.1.4" />
<PackageReference Include="Nuke.Common" Version="9.0.4" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion samples/Sample.AspNetCore/Sample.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.66.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.67.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions samples/Sample.ConsoleApp/Sample.ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.28.3" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.66.0" />
<PackageReference Include="Grpc.Tools" Version="2.67.0">
<PackageReference Include="Google.Protobuf" Version="3.29.2" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.67.0" />
<PackageReference Include="Grpc.Tools" Version="2.68.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/Auth0Net.DependencyInjection/Auth0Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static IHttpClientBuilder AddAuth0AuthenticationClientInternal(this ISer

services.AddSingleton<IAuthenticationApiClient, InjectableAuthenticationApiClient>();
return services.AddHttpClient<IAuthenticationConnection, HttpClientAuthenticationConnection>()
#if !NETSTANDARD2_0
#if !NETFRAMEWORK
.ConfigurePrimaryHttpMessageHandler(() =>
new SocketsHttpHandler()
{
Expand All @@ -116,7 +116,7 @@ public static IHttpClientBuilder AddAuth0ManagementClient(this IServiceCollectio
services.AddSingleton<IManagementApiClient, InjectableManagementApiClient>();

return services.AddHttpClient<IManagementConnection, HttpClientManagementConnection>()
#if !NETSTANDARD2_0
#if !NETFRAMEWORK
.ConfigurePrimaryHttpMessageHandler(() =>
new SocketsHttpHandler()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>4.0.0</Version>
<Version>5.0.0</Version>
<Authors>Hawxy</Authors>
<Description>Dependency Injection, HttpClientFactory &amp; ASP.NET Core extensions for Auth0.NET</Description>
<LangVersion>latest</LangVersion>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Copyright>Hawxy (JT) 2020-2024</Copyright>
<Copyright>Hawxy (JT) 2020-2025</Copyright>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Hawxy/Auth0Net.DependencyInjection</PackageProjectUrl>
Expand All @@ -21,30 +21,31 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Auth0.AuthenticationApi" Version="7.29.0" />
<PackageReference Include="Auth0.ManagementApi" Version="7.29.0" />
<PackageReference Include="Auth0.AuthenticationApi" Version="7.32.0" />
<PackageReference Include="Auth0.ManagementApi" Version="7.32.0" />
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25" PrivateAssets="All" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.4.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Polyfill" Version="7.4.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
</ItemGroup>



<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>$(MSBuildProjectName).Tests</_Parameter1>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
using System.Net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
using Polly;

namespace Auth0Net.DependencyInjection.HttpClient;

/// <summary>
/// Extensions used to enhance Auth0 client resilience.
/// </summary>
public static class Auth0ResilienceExtensions
{
/// <summary>
/// Adds enhanced rate limiting support to the Auth0 Client. This API is experimental.
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
[Experimental("Auth0DIExperimental")]
public static IHttpResiliencePipelineBuilder AddAuth0RateLimitResilience(this IHttpClientBuilder builder)
{
return builder.AddResilienceHandler("RateLimitRetry",
static builder =>
{
// See: https://www.pollydocs.org/strategies/retry.html
builder.AddRetry(new HttpRetryStrategyOptions
{
// Disable the default handling of Retry-After header
ShouldRetryAfterHeader = false,
DelayGenerator = static args =>
{
if(args.Outcome.Result?.StatusCode is (HttpStatusCode)429
&& args.Outcome.Result.Headers.TryGetValues("x-ratelimit-reset", out var headers)
&& long.TryParse(headers.First(), out var ticks))
{
var retryAt = DateTimeOffset.FromUnixTimeSeconds(ticks);
var timeSpan = retryAt - DateTimeOffset.UtcNow;
return new ValueTask<TimeSpan?>(timeSpan);
}

return new ValueTask<TimeSpan?>((TimeSpan?)null);
},

MaxRetryAttempts = 10,
Delay = TimeSpan.FromSeconds(2)
});
});
}
}

#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net.Http.Headers;
using System.Net.Http;
using System.Net.Http.Headers;
using Auth0Net.DependencyInjection.Cache;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Auth0Net.DependencyInjection.HttpClient;
using System.Net.Http;

namespace Auth0Net.DependencyInjection.HttpClient;

/// <summary>
/// Configuration used by the underlying <see cref="Auth0TokenHandler"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="FakeItEasy" Version="8.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Loading