feat(Melder): Erstellt, um aktuelle Schlüssel an den Kunden zu senden
This commit is contained in:
parent
5ab1f24ce5
commit
484cc86a29
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public interface IAuthListenHandler
|
public interface IAuthListenHandler
|
||||||
{
|
{
|
||||||
Task ReceiveKeyAsync(string topic, string key);
|
Task ReceiveKeyAsync(string name, string value);
|
||||||
}
|
}
|
||||||
@ -5,12 +5,6 @@ namespace DigitalData.Auth.API.Hubs;
|
|||||||
|
|
||||||
public class AuthHub : Hub<IAuthListenHandler>, IAuthSenderHandler
|
public class AuthHub : Hub<IAuthListenHandler>, IAuthSenderHandler
|
||||||
{
|
{
|
||||||
public async Task SendKeyAsync(string user, string message)
|
public async Task SendKeyAsync(string name, string value)
|
||||||
=> await Clients.All.ReceiveKeyAsync(user, message);
|
=> await Clients.All.ReceiveKeyAsync(name, value);
|
||||||
|
|
||||||
public async Task SendMessageToCaller(string user, string message)
|
|
||||||
=> await Clients.Caller.ReceiveKeyAsync(user, message);
|
|
||||||
|
|
||||||
public async Task SendMessageToGroup(string user, string message)
|
|
||||||
=> await Clients.Group("Auth.API Consumers").ReceiveKeyAsync(user, message);
|
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ var apiParams = config.Get<AuthApiParams>() ?? throw new InvalidOperationExcepti
|
|||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.Configure<AuthApiParams>(config);
|
builder.Services.Configure<AuthApiParams>(config);
|
||||||
builder.Services.AddConsumerService(config);
|
builder.Services.AddAuthService(config);
|
||||||
builder.Services.AddCryptoFactory(config.GetSection("CryptParams"));
|
builder.Services.AddCryptoFactory(config.GetSection("CryptParams"));
|
||||||
builder.Services.AddJwtSignatureHandler<Consumer>(api => new Dictionary<string, object>
|
builder.Services.AddJwtSignatureHandler<Consumer>(api => new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
|
|||||||
6
src/DigitalData.Auth.API/Services/Contracts/INotifier.cs
Normal file
6
src/DigitalData.Auth.API/Services/Contracts/INotifier.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace DigitalData.Auth.API.Services.Contracts;
|
||||||
|
|
||||||
|
public interface INotifier
|
||||||
|
{
|
||||||
|
Task UpdateKeyAsync(string name, string value);
|
||||||
|
}
|
||||||
@ -2,16 +2,16 @@
|
|||||||
using DigitalData.Auth.API.Services.Contracts;
|
using DigitalData.Auth.API.Services.Contracts;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace DigitalData.Auth.API.Services
|
namespace DigitalData.Auth.API.Services;
|
||||||
|
|
||||||
|
public static class DIExtensions
|
||||||
{
|
{
|
||||||
public static class DIExtensions
|
public static IServiceCollection AddAuthService(this IServiceCollection services, IConfiguration configuration, string key = "Consumers")
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddConsumerService(this IServiceCollection services, IConfiguration configuration, string key = "Consumers")
|
var consumers = configuration.GetSection(key).Get<IEnumerable<Consumer>>() ?? throw new InvalidOperationException($"No Consumer list found in {key} in configuration.");
|
||||||
{
|
services.AddSingleton(Options.Create(consumers));
|
||||||
var consumers = configuration.GetSection(key).Get<IEnumerable<Consumer>>() ?? throw new InvalidOperationException($"No Consumer list found in {key} in configuration.");
|
services.AddSingleton<IConsumerService, ConfiguredConsumerService>();
|
||||||
services.AddSingleton(Options.Create(consumers));
|
services.AddSingleton<INotifier, Notifier>();
|
||||||
services.AddSingleton<IConsumerService, ConfiguredConsumerService>();
|
return services;
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
src/DigitalData.Auth.API/Services/Notifier.cs
Normal file
21
src/DigitalData.Auth.API/Services/Notifier.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using DigitalData.Auth.Abstractions;
|
||||||
|
using DigitalData.Auth.API.Hubs;
|
||||||
|
using DigitalData.Auth.API.Services.Contracts;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace DigitalData.Auth.API.Services;
|
||||||
|
|
||||||
|
public class Notifier : INotifier
|
||||||
|
{
|
||||||
|
private readonly IHubContext<AuthHub, IAuthListenHandler> _hubContext;
|
||||||
|
|
||||||
|
public Notifier(IHubContext<AuthHub, IAuthListenHandler> hubContext)
|
||||||
|
{
|
||||||
|
_hubContext = hubContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateKeyAsync(string name, string value)
|
||||||
|
{
|
||||||
|
await _hubContext.Clients.All.ReceiveKeyAsync(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user