Reworked dotbased auth config
This commit is contained in:
@@ -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));
|
||||
}
|
Reference in New Issue
Block a user