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

@@ -1,5 +1,3 @@
using DotBased.ASP.Auth.Services;
namespace DotBased.ASP.Auth;
public class BasedAuthConfiguration
@@ -9,12 +7,36 @@ public class BasedAuthConfiguration
/// </summary>
public bool AllowRegistration { get; set; }
//TODO: Callback when a user registers, so the application can handle sending emails or generate a code to complete the registration.
//TODO: Callback for validation email, phone number
/// <summary>
/// Allow no passwords on users, not recommended!
/// </summary>
public bool AllowEmptyPassword { get; set; } = false;
/// <summary>
/// This path is used for redirecting to the login page.
/// </summary>
public string LoginPath { get; set; } = string.Empty;
/// <summary>
/// The path that will be used if the logout is requested.
/// </summary>
public string LogoutPath { get; set; } = string.Empty;
/// <summary>
/// The max age before a AuthenticationState will expire (default: 7 days).
/// </summary>
public TimeSpan AuthenticationStateMaxAgeBeforeExpire { get; set; } = TimeSpan.FromDays(7);
//TODO: Data seeding
public Action<AuthService>? SeedData { get; set; }
/// <summary>
/// Can be used to seed a default user and/or group for first time use.
/// </summary>
public Action<IAuthDataProvider>? SeedData { get; set; }
public Type? AuthDataProviderType { get; private set; }
public void SetDataProviderType<TDataProviderType>() where TDataProviderType : IAuthDataProvider =>
AuthDataProviderType = typeof(TDataProviderType);
public Type? SessionStateProviderType { get; private set; }
public void SetSessionStateProviderType<TSessionStateProviderType>()
where TSessionStateProviderType : ISessionStateProvider =>
SessionStateProviderType = typeof(TSessionStateProviderType);
}