Skip to content
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
15 changes: 12 additions & 3 deletions src/Auth0Net.DependencyInjection/Auth0Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Auth0Net.DependencyInjection.Injectables;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using IHttpClientFactory = System.Net.Http.IHttpClientFactory;

namespace Auth0Net.DependencyInjection;

Expand All @@ -13,6 +14,8 @@ namespace Auth0Net.DependencyInjection;
/// </summary>
public static class Auth0Extensions
{

private const string ManagementHttpClientKey = nameof(ManagementHttpClientKey);

/// <summary>
/// Adds an <see cref="AuthenticationApiClient" /> integrated with <see cref="IHttpClientBuilder" />.
Expand Down Expand Up @@ -117,7 +120,13 @@ public static IHttpClientBuilder AddAuth0ManagementClient(this IServiceCollectio
{
services.AddSingleton<IManagementApiClient, InjectableManagementApiClient>();

return services.AddHttpClient<IManagementConnection, HttpClientManagementConnection>()
services.AddSingleton<IManagementConnection, HttpClientManagementConnection>(x =>
{
var factory = x.GetRequiredService<IHttpClientFactory>();
return new HttpClientManagementConnection(factory.CreateClient(ManagementHttpClientKey));
});

return services.AddHttpClient(ManagementHttpClientKey)
#if NET8_0
.ConfigurePrimaryHttpMessageHandler(() =>
new SocketsHttpHandler()
Expand All @@ -130,7 +139,7 @@ public static IHttpClientBuilder AddAuth0ManagementClient(this IServiceCollectio
}

/// <summary>
/// Adds a <see cref="DelegatingHandler"/> to the <see cref="IHttpClientBuilder"/> that will automatically add a Auth0 Machine-to-Machine Access Token to the Authorization header.
/// Adds a <see cref="System.Net.Http.DelegatingHandler"/> to the <see cref="IHttpClientBuilder"/> that will automatically add a Auth0 Machine-to-Machine Access Token to the Authorization header.
/// </summary>
/// <param name="builder">The <see cref="IHttpClientBuilder"/> you wish to configure. </param>
/// <param name="config">A delegate that is used to configure the instance of <see cref="Auth0TokenHandlerConfig" />.</param>
Expand All @@ -148,7 +157,7 @@ public static IHttpClientBuilder AddAccessToken(this IHttpClientBuilder builder,
}

/// <summary>
/// Adds a <see cref="DelegatingHandler"/> to the <see cref="IHttpClientBuilder"/> that will automatically add a Auth0 Management Access Token token to the Authorization header.
/// Adds a <see cref="System.Net.Http.DelegatingHandler"/> to the <see cref="IHttpClientBuilder"/> that will automatically add a Auth0 Management Access Token token to the Authorization header.
/// </summary>
/// <remarks>
/// The domain used to resolve the token is the same as set in <see cref="AddAuth0AuthenticationClient(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{Auth0Net.DependencyInjection.Cache.Auth0Configuration})"/>, unless overriden.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>5.2.0</Version>
<Version>5.2.1</Version>
<Authors>Hawxy</Authors>
<Description>Dependency Injection, HttpClientFactory &amp; ASP.NET Core extensions for Auth0.NET</Description>
<LangVersion>latest</LangVersion>
Expand All @@ -21,8 +21,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Auth0.AuthenticationApi" Version="7.42.0" />
<PackageReference Include="Auth0.ManagementApi" Version="7.42.0" />
<PackageReference Include="Auth0.AuthenticationApi" Version="7.45.1" />
<PackageReference Include="Auth0.ManagementApi" Version="7.46.0" />
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.39" PrivateAssets="All" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.4.0" />
</ItemGroup>
Expand Down
Loading