Reworked dotbased auth config

This commit is contained in:
Max
2024-07-27 16:07:13 +02:00
parent 2b17ed4cd7
commit c092b8a679
6 changed files with 199 additions and 11 deletions

View File

@@ -14,6 +14,13 @@ public class BasedAuthBuilder
configurationAction?.Invoke(Configuration);
services.AddSingleton<BasedAuthConfiguration>(Configuration);
if (Configuration.AuthDataProviderType == null)
throw new ArgumentNullException(nameof(Configuration.AuthDataProviderType), $"No '{nameof(IAuthDataProvider)}' configured!");
services.AddScoped(typeof(IAuthDataProvider), Configuration.AuthDataProviderType);
if (Configuration.SessionStateProviderType == null)
throw new ArgumentNullException(nameof(Configuration.SessionStateProviderType), $"No '{nameof(ISessionStateProvider)}' configured!");
services.AddScoped(typeof(ISessionStateProvider), Configuration.SessionStateProviderType);
services.AddScoped<AuthService>();
services.AddScoped<AuthenticationStateProvider, BasedServerAuthenticationStateProvider>();
@@ -26,6 +33,4 @@ public class BasedAuthBuilder
}
public BasedAuthConfiguration Configuration { get; }
private readonly IServiceCollection _services;
public void AddSessionStateProvider<TSessionStateProviderType>() where TSessionStateProviderType : ISessionStateProvider => _services.AddScoped(typeof(ISessionStateProvider), typeof(TSessionStateProviderType));
}