feat(AuthClient): implementierte Methode PublicKeys.get
- GetAllPublicKeysAsync Methode hinzugefügt, um GetPublicKeyAsync Methode für jeden öffentlichen Schlüssel aufzurufen. - Aktualisiert, um GetAllPublicKeysAsync Methode nach erfolgreichem Start und Wiederverbindung aufzurufen
This commit is contained in:
parent
8682f1f9e0
commit
6198008475
@ -10,5 +10,5 @@ public class AsymmetricPublicKey : IUniqueSecurityContext, IAsymmetricPublicKey
|
||||
|
||||
public string? Id { get; init; }
|
||||
|
||||
public string Content { get; protected set; } = string.Empty;
|
||||
public string Content { get; internal set; } = string.Empty;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using DigitalData.Auth.Abstractions;
|
||||
using DigitalData.Auth.Abstractions.Models;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
@ -27,15 +28,20 @@ public class AuthClient : IAuthClient, IAsyncDisposable
|
||||
|
||||
_connection.On<string, string, string>(nameof(ReceivePublicKeyAsync), ReceivePublicKeyAsync);
|
||||
|
||||
_connection.Reconnected += async cnnId => await GetAllPublicKeysAsync();
|
||||
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public bool IsConnected { get; private set; } = false;
|
||||
|
||||
public IEnumerable<AsymmetricPublicKey> PublicKeys => _params.PublicKeys;
|
||||
|
||||
public async Task StartAsync()
|
||||
{
|
||||
await _connection.StartAsync();
|
||||
IsConnected = true;
|
||||
await GetAllPublicKeysAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> TryStartAsync()
|
||||
@ -58,6 +64,12 @@ public class AuthClient : IAuthClient, IAsyncDisposable
|
||||
|
||||
public Task GetPublicKeyAsync(string issuer, string audience) => _connection.InvokeAsync(nameof(GetPublicKeyAsync), issuer, audience);
|
||||
|
||||
public async Task GetAllPublicKeysAsync()
|
||||
{
|
||||
foreach (var publicKey in PublicKeys)
|
||||
await GetPublicKeyAsync(publicKey.Issuer, publicKey.Audience);
|
||||
}
|
||||
|
||||
public virtual async ValueTask DisposeAsync()
|
||||
{
|
||||
await _connection.StopAsync();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using DigitalData.Auth.Abstractions.Models;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
namespace DigitalData.Auth.Client;
|
||||
|
||||
@ -36,4 +37,6 @@ public class ClientParams
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<AsymmetricPublicKey> PublicKeys { get; init; } = new List<AsymmetricPublicKey>();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user