Working base login

This commit is contained in:
max
2024-11-02 01:57:25 +01:00
parent d98634d888
commit 8531079a16
10 changed files with 217 additions and 163 deletions

View File

@@ -1,4 +1,3 @@
using DotBased.ASP.Auth.Scheme;
using DotBased.ASP.Auth.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components.Authorization;
@@ -23,18 +22,18 @@ public static class DotBasedAuthDependencyInjection
if (Configuration.AuthDataRepositoryType == null)
throw new ArgumentNullException(nameof(Configuration.AuthDataRepositoryType), $"No '{nameof(IAuthDataRepository)}' configured!");
services.AddScoped(typeof(IAuthDataRepository), Configuration.AuthDataRepositoryType);
if (Configuration.SessionStateProviderType == null)
/*if (Configuration.SessionStateProviderType == null)
throw new ArgumentNullException(nameof(Configuration.SessionStateProviderType), $"No '{nameof(ISessionStateProvider)}' configured!");
services.AddScoped(typeof(ISessionStateProvider), Configuration.SessionStateProviderType);
services.AddScoped(typeof(ISessionStateProvider), Configuration.SessionStateProviderType);*/
services.AddSingleton<AuthDataCache>();
services.AddScoped<AuthService>();
services.AddScoped<SecurityService>();
services.AddScoped<AuthenticationStateProvider, BasedServerAuthenticationStateProvider>();
services.AddAuthentication(options =>
{
options.DefaultScheme = BasedAuthenticationHandler.AuthenticationScheme;
}).AddScheme<BasedAuthenticationHandlerOptions, BasedAuthenticationHandler>(BasedAuthenticationHandler.AuthenticationScheme, null);
options.DefaultScheme = BasedAuthDefaults.AuthenticationScheme;
});/*.AddScheme<BasedAuthenticationHandlerOptions, BasedAuthenticationHandler>(BasedAuthDefaults.AuthenticationScheme, null);*/
services.AddAuthorization();
services.AddCascadingAuthenticationState();
return services;