using DotBased.ASP.Auth.Scheme; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.DependencyInjection; namespace DotBased.ASP.Auth; public static class DotBasedAuthDependencyInjection { /// /// Use the DotBased authentication implementation /// /// Use the app.UseAuthentication() and app.UseAuthorization()! /// Service colllection /// DotBased auth configuration public static void UseBasedAuth(this IServiceCollection services, Action? configurationAction = null) { var config = new BasedAuthConfiguration(); configurationAction?.Invoke(config); services.AddSingleton(config); services.AddScoped(); services.AddAuthentication(options => { options.DefaultScheme = BasedAuthenticationHandler.AuthenticationScheme; }).AddScheme(BasedAuthenticationHandler.AuthenticationScheme, null); services.AddAuthorization(); } }