From 4580c5f5dc53886a48dcb07e1a918484197693cd Mon Sep 17 00:00:00 2001 From: max Date: Sun, 1 Dec 2024 03:13:55 +0100 Subject: [PATCH 1/2] Reimplementing Authorization system --- DotBased.ASP.Auth/AuthenticationService.cs | 13 +++++++ DotBased.ASP.Auth/BasedAuthConfiguration.cs | 15 ++++++++ .../BasedServerAuthenticationStateProvider.cs | 1 - DotBased.ASP.Auth/DotBased.ASP.Auth.csproj | 5 +++ .../DotBasedAuthDependencyInjection.cs | 1 - .../Models/Configuration/AuthConfiguration.cs | 11 ++++++ .../Configuration/CacheConfiguration.cs | 6 ++++ .../Configuration/LockoutConfiguration.cs | 6 ++++ .../Configuration/PasswordConfiguration.cs | 6 ++++ .../Configuration/ProviderConfiguration.cs | 6 ++++ .../Configuration/RepositoryConfiguration.cs | 6 ++++ .../Models/Configuration/UserConfiguration.cs | 6 ++++ DotBased.ASP.Auth/SecurityManager.cs | 9 +++++ .../{Services => }/SecurityService.cs | 4 +-- .../BasedAuthenticationBuilder.cs | 16 +++++++++ .../BasedAuthenticationExtensions.cs | 34 +++++++++++++++++++ .../BasedAuthenticationStateProvider.cs | 11 ++++++ .../AuthenticationConfiguration.cs | 9 +++++ .../Configuration/CacheConfiguration.cs | 6 ++++ .../Configuration/LockoutConfiguration.cs | 6 ++++ .../Configuration/PasswordConfiguration.cs | 6 ++++ .../Configuration/UserConfiguration.cs | 6 ++++ .../Providers/IStateProvider.cs | 6 ++++ .../Repositories/IAttributeRepository.cs | 6 ++++ .../Repositories/IAuthenticationRepository.cs | 6 ++++ .../Repositories/IGroupRepository.cs | 6 ++++ .../Repositories/IRoleRepository.cs | 6 ++++ .../Repositories/ISessionRepository.cs | 6 ++++ .../Repositories/IUserRepository.cs | 6 ++++ .../Repositories/RepositoryBase.cs | 6 ++++ .../SecurityManager.cs | 17 ++++++++++ 31 files changed, 250 insertions(+), 4 deletions(-) create mode 100644 DotBased.ASP.Auth/AuthenticationService.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/AuthConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/CacheConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/LockoutConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/PasswordConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/ProviderConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/RepositoryConfiguration.cs create mode 100644 DotBased.ASP.Auth/Models/Configuration/UserConfiguration.cs create mode 100644 DotBased.ASP.Auth/SecurityManager.cs rename DotBased.ASP.Auth/{Services => }/SecurityService.cs (96%) create mode 100644 DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs create mode 100644 DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs create mode 100644 DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs create mode 100644 DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs create mode 100644 DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs create mode 100644 DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs create mode 100644 DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs create mode 100644 DotBased.ASP.Authentication/Configuration/UserConfiguration.cs create mode 100644 DotBased.ASP.Authentication/Providers/IStateProvider.cs create mode 100644 DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/IGroupRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/IRoleRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/ISessionRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/IUserRepository.cs create mode 100644 DotBased.ASP.Authentication/Repositories/RepositoryBase.cs create mode 100644 DotBased.ASP.Authentication/SecurityManager.cs diff --git a/DotBased.ASP.Auth/AuthenticationService.cs b/DotBased.ASP.Auth/AuthenticationService.cs new file mode 100644 index 0000000..9b4d3b2 --- /dev/null +++ b/DotBased.ASP.Auth/AuthenticationService.cs @@ -0,0 +1,13 @@ +namespace DotBased.ASP.Auth.Services; + +public class AuthenticationService +{ + public AuthenticationService() + { + /* + * - Login + * - Logout + * - Register + */ + } +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/BasedAuthConfiguration.cs b/DotBased.ASP.Auth/BasedAuthConfiguration.cs index befc359..a6871ba 100644 --- a/DotBased.ASP.Auth/BasedAuthConfiguration.cs +++ b/DotBased.ASP.Auth/BasedAuthConfiguration.cs @@ -47,4 +47,19 @@ public class BasedAuthConfiguration public void SetSessionStateProviderType() where TSessionStateProviderType : ISessionStateProvider => SessionStateProviderType = typeof(TSessionStateProviderType); +} + +public class BasedPasswordOptions +{ + +} + +public class BasedUserOptions +{ + +} + +public class BasedLockoutOptions +{ + } \ No newline at end of file diff --git a/DotBased.ASP.Auth/BasedServerAuthenticationStateProvider.cs b/DotBased.ASP.Auth/BasedServerAuthenticationStateProvider.cs index c2f7aea..0863561 100644 --- a/DotBased.ASP.Auth/BasedServerAuthenticationStateProvider.cs +++ b/DotBased.ASP.Auth/BasedServerAuthenticationStateProvider.cs @@ -1,5 +1,4 @@ using System.Security.Claims; -using DotBased.ASP.Auth.Services; using DotBased.Logging; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Server; diff --git a/DotBased.ASP.Auth/DotBased.ASP.Auth.csproj b/DotBased.ASP.Auth/DotBased.ASP.Auth.csproj index ba40443..f6176e4 100644 --- a/DotBased.ASP.Auth/DotBased.ASP.Auth.csproj +++ b/DotBased.ASP.Auth/DotBased.ASP.Auth.csproj @@ -17,4 +17,9 @@ + + + + + diff --git a/DotBased.ASP.Auth/DotBasedAuthDependencyInjection.cs b/DotBased.ASP.Auth/DotBasedAuthDependencyInjection.cs index 4366532..c64cbca 100644 --- a/DotBased.ASP.Auth/DotBasedAuthDependencyInjection.cs +++ b/DotBased.ASP.Auth/DotBasedAuthDependencyInjection.cs @@ -18,7 +18,6 @@ public static class DotBasedAuthDependencyInjection var Configuration = new BasedAuthConfiguration(); configurationAction?.Invoke(Configuration); - services.AddSingleton(Configuration); if (Configuration.AuthDataRepositoryType == null) throw new ArgumentNullException(nameof(Configuration.AuthDataRepositoryType), $"No '{nameof(IAuthDataRepository)}' configured!"); diff --git a/DotBased.ASP.Auth/Models/Configuration/AuthConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/AuthConfiguration.cs new file mode 100644 index 0000000..2bbf690 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/AuthConfiguration.cs @@ -0,0 +1,11 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class AuthConfiguration +{ + public CacheConfiguration Cache { get; set; } = new(); + public LockoutConfiguration Lockout { get; set; } = new(); + public PasswordConfiguration Password { get; set; } = new(); + public ProviderConfiguration Provider { get; set; } = new(); + public RepositoryConfiguration Repository { get; set; } = new(); + public UserConfiguration User { get; set; } = new(); +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/CacheConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/CacheConfiguration.cs new file mode 100644 index 0000000..8647941 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/CacheConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class CacheConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/LockoutConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/LockoutConfiguration.cs new file mode 100644 index 0000000..b59ae65 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/LockoutConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class LockoutConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/PasswordConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/PasswordConfiguration.cs new file mode 100644 index 0000000..c590cdd --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/PasswordConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class PasswordConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/ProviderConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/ProviderConfiguration.cs new file mode 100644 index 0000000..cf3f702 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/ProviderConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class ProviderConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/RepositoryConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/RepositoryConfiguration.cs new file mode 100644 index 0000000..cb55903 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/RepositoryConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class RepositoryConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Models/Configuration/UserConfiguration.cs b/DotBased.ASP.Auth/Models/Configuration/UserConfiguration.cs new file mode 100644 index 0000000..a4dd082 --- /dev/null +++ b/DotBased.ASP.Auth/Models/Configuration/UserConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Auth.Models.Configuration; + +public class UserConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/SecurityManager.cs b/DotBased.ASP.Auth/SecurityManager.cs new file mode 100644 index 0000000..0067eae --- /dev/null +++ b/DotBased.ASP.Auth/SecurityManager.cs @@ -0,0 +1,9 @@ +namespace DotBased.ASP.Auth.Managers; + +public class SecurityManager +{ + public SecurityManager() + { + + } +} \ No newline at end of file diff --git a/DotBased.ASP.Auth/Services/SecurityService.cs b/DotBased.ASP.Auth/SecurityService.cs similarity index 96% rename from DotBased.ASP.Auth/Services/SecurityService.cs rename to DotBased.ASP.Auth/SecurityService.cs index 851c0a5..748e0a7 100644 --- a/DotBased.ASP.Auth/Services/SecurityService.cs +++ b/DotBased.ASP.Auth/SecurityService.cs @@ -7,7 +7,7 @@ using DotBased.Logging; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; -namespace DotBased.ASP.Auth.Services; +namespace DotBased.ASP.Auth; public class SecurityService { @@ -60,9 +60,9 @@ public class SecurityService new(ClaimTypes.Surname, userResult.Value.FamilyName), new(ClaimTypes.Email, userResult.Value.Email) }; - //TODO: combine group, user roles claims.AddRange(userResult.Value.Groups.Select(group => new Claim(ClaimTypes.GroupSid, group.Id))); claims.AddRange(userResult.Value.Roles.Select(role => new Claim(ClaimTypes.Role, role.Name))); + claims.AddRange(userResult.Value.Groups.Select(g => g.Roles).SelectMany(gRolesList => gRolesList, (_, role) => new Claim(ClaimTypes.Role, role.Name))); var claimsIdentity = new ClaimsIdentity(claims, BasedAuthDefaults.AuthenticationScheme); var authState = new AuthenticationState(new ClaimsPrincipal(claimsIdentity)); _dataCache.CacheSessionState(authStateModel, authState); diff --git a/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs b/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs new file mode 100644 index 0000000..fe65321 --- /dev/null +++ b/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs @@ -0,0 +1,16 @@ +namespace DotBased.ASP.Authentication; + +public class BasedAuthenticationBuilder +{ + public BasedAuthenticationBuilder(Type authRepository) + { + if (authRepository.IsValueType) + { + throw new ArgumentException("Type cannot be a value type!", nameof(authRepository)); + } + + AuthenticationRepositoryType = authRepository; + } + + public Type AuthenticationRepositoryType { get; } +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs b/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs new file mode 100644 index 0000000..e1cbf38 --- /dev/null +++ b/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs @@ -0,0 +1,34 @@ +using DotBased.ASP.Authentication.Configuration; +using DotBased.ASP.Authentication.Repositories; +using Microsoft.Extensions.DependencyInjection; + +namespace DotBased.ASP.Authentication; + +public static class BasedAuthenticationExtensions +{ + public static BasedAuthenticationBuilder AddBasedAuthentication(this IServiceCollection services, Action? configurationAction) + { + /* + * Add services + * - Validators + * - Managers + * - Services + */ + if (configurationAction != null) + { + services.Configure(configurationAction); + } + + return new BasedAuthenticationBuilder(typeof(BasedAuthenticationBuilder)); + } + + public static BasedAuthenticationBuilder AddRepository(this BasedAuthenticationBuilder builder) + { + return builder; + } + + public static BasedAuthenticationBuilder SeedData(this BasedAuthenticationBuilder builder, Action seeder) where TRepository : RepositoryBase + { + return builder; + } +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs b/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs new file mode 100644 index 0000000..9cf1969 --- /dev/null +++ b/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Components.Authorization; + +namespace DotBased.ASP.Authentication; + +public class BasedAuthenticationStateProvider : AuthenticationStateProvider +{ + public override async Task GetAuthenticationStateAsync() + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs b/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs new file mode 100644 index 0000000..8ff6f8a --- /dev/null +++ b/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs @@ -0,0 +1,9 @@ +namespace DotBased.ASP.Authentication.Configuration; + +public class AuthenticationConfiguration +{ + public CacheConfiguration Cache { get; set; } = new(); + public LockoutConfiguration Lockout { get; set; } = new(); + public PasswordConfiguration Password { get; set; } = new(); + public UserConfiguration User { get; set; } = new(); +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs b/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs new file mode 100644 index 0000000..9aa2d8e --- /dev/null +++ b/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Configuration; + +public class CacheConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs b/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs new file mode 100644 index 0000000..ac83a60 --- /dev/null +++ b/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Configuration; + +public class LockoutConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs b/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs new file mode 100644 index 0000000..acfa7eb --- /dev/null +++ b/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Configuration; + +public class PasswordConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs b/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs new file mode 100644 index 0000000..c98ca99 --- /dev/null +++ b/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Configuration; + +public class UserConfiguration +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Providers/IStateProvider.cs b/DotBased.ASP.Authentication/Providers/IStateProvider.cs new file mode 100644 index 0000000..a561af8 --- /dev/null +++ b/DotBased.ASP.Authentication/Providers/IStateProvider.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Providers; + +public interface IStateProvider +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs b/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs new file mode 100644 index 0000000..1899714 --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface IAttributeRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs b/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs new file mode 100644 index 0000000..6e71768 --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface IAuthenticationRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs b/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs new file mode 100644 index 0000000..67b0772 --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface IGroupRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs b/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs new file mode 100644 index 0000000..bbe4dbf --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface IRoleRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs b/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs new file mode 100644 index 0000000..114183f --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface ISessionRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IUserRepository.cs b/DotBased.ASP.Authentication/Repositories/IUserRepository.cs new file mode 100644 index 0000000..867cf90 --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/IUserRepository.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public interface IUserRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs b/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs new file mode 100644 index 0000000..bad4fe7 --- /dev/null +++ b/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs @@ -0,0 +1,6 @@ +namespace DotBased.ASP.Authentication.Repositories; + +public abstract class RepositoryBase : IAuthenticationRepository, IAttributeRepository, IGroupRepository, ISessionRepository, IUserRepository +{ + +} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/SecurityManager.cs b/DotBased.ASP.Authentication/SecurityManager.cs new file mode 100644 index 0000000..b19b93d --- /dev/null +++ b/DotBased.ASP.Authentication/SecurityManager.cs @@ -0,0 +1,17 @@ +using DotBased.ASP.Authentication.Configuration; +using DotBased.Logging; +using Microsoft.Extensions.Options; + +namespace DotBased.ASP.Authentication; + +public class SecurityManager +{ + public SecurityManager(IServiceProvider services, IOptions? config) + { + _services = services; + Configuration = config?.Value ?? new AuthenticationConfiguration(); + } + private ILogger _logger = LogService.RegisterLogger(); + private IServiceProvider _services; + public AuthenticationConfiguration Configuration { get; set; } +} \ No newline at end of file From 1b080ae5c7ee66b00addbec5e21ec5c8b2adc314 Mon Sep 17 00:00:00 2001 From: max Date: Sun, 1 Dec 2024 16:52:53 +0100 Subject: [PATCH 2/2] Deleted authentication package (later implementation) --- .../BasedAuthenticationBuilder.cs | 16 --------- .../BasedAuthenticationExtensions.cs | 34 ------------------- .../BasedAuthenticationStateProvider.cs | 11 ------ .../AuthenticationConfiguration.cs | 9 ----- .../Configuration/CacheConfiguration.cs | 6 ---- .../Configuration/LockoutConfiguration.cs | 6 ---- .../Configuration/PasswordConfiguration.cs | 6 ---- .../Configuration/UserConfiguration.cs | 6 ---- .../DotBased.ASP.Authentication.csproj | 17 ---------- .../Providers/IStateProvider.cs | 6 ---- .../Repositories/IAttributeRepository.cs | 6 ---- .../Repositories/IAuthenticationRepository.cs | 6 ---- .../Repositories/IGroupRepository.cs | 6 ---- .../Repositories/IRoleRepository.cs | 6 ---- .../Repositories/ISessionRepository.cs | 6 ---- .../Repositories/IUserRepository.cs | 6 ---- .../Repositories/RepositoryBase.cs | 6 ---- .../SecurityManager.cs | 17 ---------- 18 files changed, 176 deletions(-) delete mode 100644 DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs delete mode 100644 DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs delete mode 100644 DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs delete mode 100644 DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs delete mode 100644 DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs delete mode 100644 DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs delete mode 100644 DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs delete mode 100644 DotBased.ASP.Authentication/Configuration/UserConfiguration.cs delete mode 100644 DotBased.ASP.Authentication/DotBased.ASP.Authentication.csproj delete mode 100644 DotBased.ASP.Authentication/Providers/IStateProvider.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/IGroupRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/IRoleRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/ISessionRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/IUserRepository.cs delete mode 100644 DotBased.ASP.Authentication/Repositories/RepositoryBase.cs delete mode 100644 DotBased.ASP.Authentication/SecurityManager.cs diff --git a/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs b/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs deleted file mode 100644 index fe65321..0000000 --- a/DotBased.ASP.Authentication/BasedAuthenticationBuilder.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace DotBased.ASP.Authentication; - -public class BasedAuthenticationBuilder -{ - public BasedAuthenticationBuilder(Type authRepository) - { - if (authRepository.IsValueType) - { - throw new ArgumentException("Type cannot be a value type!", nameof(authRepository)); - } - - AuthenticationRepositoryType = authRepository; - } - - public Type AuthenticationRepositoryType { get; } -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs b/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs deleted file mode 100644 index e1cbf38..0000000 --- a/DotBased.ASP.Authentication/BasedAuthenticationExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using DotBased.ASP.Authentication.Configuration; -using DotBased.ASP.Authentication.Repositories; -using Microsoft.Extensions.DependencyInjection; - -namespace DotBased.ASP.Authentication; - -public static class BasedAuthenticationExtensions -{ - public static BasedAuthenticationBuilder AddBasedAuthentication(this IServiceCollection services, Action? configurationAction) - { - /* - * Add services - * - Validators - * - Managers - * - Services - */ - if (configurationAction != null) - { - services.Configure(configurationAction); - } - - return new BasedAuthenticationBuilder(typeof(BasedAuthenticationBuilder)); - } - - public static BasedAuthenticationBuilder AddRepository(this BasedAuthenticationBuilder builder) - { - return builder; - } - - public static BasedAuthenticationBuilder SeedData(this BasedAuthenticationBuilder builder, Action seeder) where TRepository : RepositoryBase - { - return builder; - } -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs b/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs deleted file mode 100644 index 9cf1969..0000000 --- a/DotBased.ASP.Authentication/BasedAuthenticationStateProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.AspNetCore.Components.Authorization; - -namespace DotBased.ASP.Authentication; - -public class BasedAuthenticationStateProvider : AuthenticationStateProvider -{ - public override async Task GetAuthenticationStateAsync() - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs b/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs deleted file mode 100644 index 8ff6f8a..0000000 --- a/DotBased.ASP.Authentication/Configuration/AuthenticationConfiguration.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DotBased.ASP.Authentication.Configuration; - -public class AuthenticationConfiguration -{ - public CacheConfiguration Cache { get; set; } = new(); - public LockoutConfiguration Lockout { get; set; } = new(); - public PasswordConfiguration Password { get; set; } = new(); - public UserConfiguration User { get; set; } = new(); -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs b/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs deleted file mode 100644 index 9aa2d8e..0000000 --- a/DotBased.ASP.Authentication/Configuration/CacheConfiguration.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Configuration; - -public class CacheConfiguration -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs b/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs deleted file mode 100644 index ac83a60..0000000 --- a/DotBased.ASP.Authentication/Configuration/LockoutConfiguration.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Configuration; - -public class LockoutConfiguration -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs b/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs deleted file mode 100644 index acfa7eb..0000000 --- a/DotBased.ASP.Authentication/Configuration/PasswordConfiguration.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Configuration; - -public class PasswordConfiguration -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs b/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs deleted file mode 100644 index c98ca99..0000000 --- a/DotBased.ASP.Authentication/Configuration/UserConfiguration.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Configuration; - -public class UserConfiguration -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/DotBased.ASP.Authentication.csproj b/DotBased.ASP.Authentication/DotBased.ASP.Authentication.csproj deleted file mode 100644 index 85639a9..0000000 --- a/DotBased.ASP.Authentication/DotBased.ASP.Authentication.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - diff --git a/DotBased.ASP.Authentication/Providers/IStateProvider.cs b/DotBased.ASP.Authentication/Providers/IStateProvider.cs deleted file mode 100644 index a561af8..0000000 --- a/DotBased.ASP.Authentication/Providers/IStateProvider.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Providers; - -public interface IStateProvider -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs b/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs deleted file mode 100644 index 1899714..0000000 --- a/DotBased.ASP.Authentication/Repositories/IAttributeRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface IAttributeRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs b/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs deleted file mode 100644 index 6e71768..0000000 --- a/DotBased.ASP.Authentication/Repositories/IAuthenticationRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface IAuthenticationRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs b/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs deleted file mode 100644 index 67b0772..0000000 --- a/DotBased.ASP.Authentication/Repositories/IGroupRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface IGroupRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs b/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs deleted file mode 100644 index bbe4dbf..0000000 --- a/DotBased.ASP.Authentication/Repositories/IRoleRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface IRoleRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs b/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs deleted file mode 100644 index 114183f..0000000 --- a/DotBased.ASP.Authentication/Repositories/ISessionRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface ISessionRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/IUserRepository.cs b/DotBased.ASP.Authentication/Repositories/IUserRepository.cs deleted file mode 100644 index 867cf90..0000000 --- a/DotBased.ASP.Authentication/Repositories/IUserRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public interface IUserRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs b/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs deleted file mode 100644 index bad4fe7..0000000 --- a/DotBased.ASP.Authentication/Repositories/RepositoryBase.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DotBased.ASP.Authentication.Repositories; - -public abstract class RepositoryBase : IAuthenticationRepository, IAttributeRepository, IGroupRepository, ISessionRepository, IUserRepository -{ - -} \ No newline at end of file diff --git a/DotBased.ASP.Authentication/SecurityManager.cs b/DotBased.ASP.Authentication/SecurityManager.cs deleted file mode 100644 index b19b93d..0000000 --- a/DotBased.ASP.Authentication/SecurityManager.cs +++ /dev/null @@ -1,17 +0,0 @@ -using DotBased.ASP.Authentication.Configuration; -using DotBased.Logging; -using Microsoft.Extensions.Options; - -namespace DotBased.ASP.Authentication; - -public class SecurityManager -{ - public SecurityManager(IServiceProvider services, IOptions? config) - { - _services = services; - Configuration = config?.Value ?? new AuthenticationConfiguration(); - } - private ILogger _logger = LogService.RegisterLogger(); - private IServiceProvider _services; - public AuthenticationConfiguration Configuration { get; set; } -} \ No newline at end of file