feat(DIExtensions): Optionale IConfiguration-Eingabe hinzugefügt, um AddAuthHubClient mit Hilfe von Appsettings konfigurieren zu können
This commit is contained in:
parent
48f5c69c91
commit
106d31b068
@ -1,5 +1,4 @@
|
||||
using DigitalData.Auth.Client;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DigitalData.Auth.Client;
|
||||
@ -42,5 +41,5 @@ public class ClientParams
|
||||
});
|
||||
}
|
||||
|
||||
public List<AsymmetricPublicKey> PublicKeys { get; init; } = new();
|
||||
public List<AsymmetricPublicKey> PublicKeys { get; set; } = new();
|
||||
}
|
||||
@ -1,17 +1,21 @@
|
||||
using DigitalData.Auth.Abstractions;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace DigitalData.Auth.Client;
|
||||
|
||||
public static class DIExtensions
|
||||
{
|
||||
public static IServiceCollection AddAuthHubClient(this IServiceCollection services, Action<ClientParams> options)
|
||||
public static IServiceCollection AddAuthHubClient(this IServiceCollection services, IConfiguration? configuration = null, Action<ClientParams>? options = null)
|
||||
{
|
||||
var clientParams = configuration?.GetSection(nameof(ClientParams)).Get<ClientParams>() ?? new ClientParams();
|
||||
options?.Invoke(clientParams);
|
||||
services
|
||||
.Configure(options)
|
||||
.AddSingleton<IAuthClient, AuthClient>()
|
||||
.AddSingleton(Options.Create(clientParams))
|
||||
.AddSingleton<IAuthClient, AuthClient>()
|
||||
.TryAddSingleton<HubConnectionBuilder>();
|
||||
|
||||
return services;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PackageId>DigitalData.Auth.Client</PackageId>
|
||||
<Version>1.1.1</Version>
|
||||
<Version>1.1.2</Version>
|
||||
<Description>DigitalData.Auth.Client is a SignalR-based authentication client that enables applications to connect to a central authentication hub for real-time message exchange. It provides seamless connection management, automatic reconnection (RetryPolicy), and event-driven communication (ClientEvents). The package includes dependency injection support via DIExtensions, allowing easy integration into ASP.NET Core applications. With built-in retry policies and secure message handling, it ensures a reliable and scalable authentication client for real-time authentication workflows.</Description>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<Product>Digital Data GmbH</Product>
|
||||
@ -14,8 +14,8 @@
|
||||
<PackageIcon>auth_icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/DigitalData.Auth</RepositoryUrl>
|
||||
<PackageTags>Digital Data Auth Authorization Authentication</PackageTags>
|
||||
<AssemblyVersion>1.1.1</AssemblyVersion>
|
||||
<FileVersion>1.1.1</FileVersion>
|
||||
<AssemblyVersion>1.1.2</AssemblyVersion>
|
||||
<FileVersion>1.1.2</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -40,7 +40,7 @@ public class AuthHubTests
|
||||
Build = options =>
|
||||
{
|
||||
var provider = new ServiceCollection()
|
||||
.AddAuthHubClient(options)
|
||||
.AddAuthHubClient(options: options)
|
||||
.BuildServiceProvider();
|
||||
|
||||
_disposableAsync.Enqueue(provider);
|
||||
|
||||
@ -85,7 +85,7 @@ public class AuthClientTests
|
||||
Build = options =>
|
||||
{
|
||||
var provider = new ServiceCollection()
|
||||
.AddAuthHubClient(options)
|
||||
.AddAuthHubClient(options: options)
|
||||
.BuildServiceProvider();
|
||||
|
||||
_disposableAsync.Enqueue(provider);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user