[CHANGE] Building data structure
This commit is contained in:
0
DotBased.AspNet.Authority/Attributes/ProtectAttribute.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Attributes/ProtectAttribute.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityBuilder.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityBuilder.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityDefaults.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityDefaults.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityProviderExtensions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/AuthorityProviderExtensions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/Cryptographer.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/Cryptographer.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/ICryptographer.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/ICryptographer.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/IPasswordHasher.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/IPasswordHasher.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/PasswordHasher.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Crypto/PasswordHasher.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/DotBased.AspNet.Authority.csproj
Normal file → Executable file
0
DotBased.AspNet.Authority/DotBased.AspNet.Authority.csproj
Normal file → Executable file
6
DotBased.AspNet.Authority/Managers/AuthorityGroupManager.cs
Normal file → Executable file
6
DotBased.AspNet.Authority/Managers/AuthorityGroupManager.cs
Normal file → Executable file
@@ -2,5 +2,9 @@ namespace DotBased.AspNet.Authority.Managers;
|
||||
|
||||
public partial class AuthorityManager
|
||||
{
|
||||
|
||||
/*
|
||||
* - Validate User & Group
|
||||
* - Check if user is already in group (if already in group return)
|
||||
* - Add to UsersGroups table
|
||||
*/
|
||||
}
|
43
DotBased.AspNet.Authority/Managers/AuthorityManager.cs
Normal file → Executable file
43
DotBased.AspNet.Authority/Managers/AuthorityManager.cs
Normal file → Executable file
@@ -9,36 +9,25 @@ using Microsoft.Extensions.Options;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Managers;
|
||||
|
||||
public partial class AuthorityManager
|
||||
public partial class AuthorityManager(
|
||||
IOptions<AuthorityOptions> options,
|
||||
IServiceProvider services,
|
||||
ICryptographer cryptographer,
|
||||
IUserRepository userRepository,
|
||||
IRoleRepository roleRepository,
|
||||
IPasswordHasher passwordHasher)
|
||||
{
|
||||
public AuthorityManager(
|
||||
IOptions<AuthorityOptions> options,
|
||||
IServiceProvider services,
|
||||
ICryptographer cryptographer,
|
||||
IUserRepository userRepository,
|
||||
IRoleRepository roleRepository,
|
||||
IPasswordHasher passwordHasher)
|
||||
{
|
||||
_logger = LogService.RegisterLogger<AuthorityManager>();
|
||||
Options = options.Value;
|
||||
Services = services;
|
||||
Cryptographer = cryptographer;
|
||||
UserRepository = userRepository;
|
||||
RoleRepository = roleRepository;
|
||||
PasswordHasher = passwordHasher;
|
||||
}
|
||||
private readonly ILogger _logger = LogService.RegisterLogger<AuthorityManager>();
|
||||
|
||||
private readonly ILogger _logger;
|
||||
public IServiceProvider Services { get; } = services;
|
||||
public AuthorityOptions Options { get; } = options.Value;
|
||||
public ICryptographer Cryptographer { get; } = cryptographer;
|
||||
|
||||
public IUserRepository UserRepository { get; } = userRepository;
|
||||
public IRoleRepository RoleRepository { get; } = roleRepository;
|
||||
|
||||
public IPasswordHasher PasswordHasher { get; } = passwordHasher;
|
||||
|
||||
public IServiceProvider Services { get; }
|
||||
public AuthorityOptions Options { get; }
|
||||
public ICryptographer Cryptographer { get; }
|
||||
|
||||
public IUserRepository UserRepository { get; }
|
||||
public IRoleRepository RoleRepository { get; }
|
||||
|
||||
public IPasswordHasher PasswordHasher { get; }
|
||||
|
||||
public IEnumerable<IPasswordValidator> PasswordValidators { get; } = [];
|
||||
public IEnumerable<IUserValidator> UserValidators { get; } = [];
|
||||
|
||||
|
33
DotBased.AspNet.Authority/Managers/AuthorityRoleManager.cs
Normal file → Executable file
33
DotBased.AspNet.Authority/Managers/AuthorityRoleManager.cs
Normal file → Executable file
@@ -19,9 +19,22 @@ public partial class AuthorityManager
|
||||
return Result<AuthorityRole>.Failed("Not implemented!");
|
||||
}
|
||||
|
||||
public async Task<ListResult<AuthorityRole>> GetRolesAsync(int limit = 20, int offset = 0, string search = "", CancellationToken? cancellationToken = null)
|
||||
{
|
||||
/*
|
||||
* Search by role name & id
|
||||
* Order by name, created date, creator? (paging)
|
||||
*/
|
||||
return ListResult<AuthorityRole>.Failed("Not implemented!");
|
||||
}
|
||||
|
||||
public async Task AddRoleToUserAsync(AuthorityUser user, AuthorityRole role, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
|
||||
/*
|
||||
- Validate User & Role
|
||||
- Check if role is already in linked to user (if user already has the role, return)
|
||||
- Add to UsersRoles table
|
||||
*/
|
||||
}
|
||||
|
||||
public async Task RemoveRoleFromUserAsync(AuthorityRole role, AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
@@ -31,4 +44,22 @@ public partial class AuthorityManager
|
||||
public async Task AddRoleToGroupAsync(AuthorityRole role, AuthorityGroup group, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all roles (including group roles) that the user has.
|
||||
/// </summary>
|
||||
/// <param name="user">The user to get the roles from</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
public async Task<ListResult<AuthorityRole>> GetUserRolesAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
/*
|
||||
* - Validate user
|
||||
* - Get user groups (id)
|
||||
* - Get roles contained from user
|
||||
* - Get roles contained from groups (if any)
|
||||
* - Order by (for paging)
|
||||
*/
|
||||
|
||||
return ListResult<AuthorityRole>.Failed("Not implemented!");
|
||||
}
|
||||
}
|
0
DotBased.AspNet.Authority/Managers/AuthorityUserManager.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Managers/AuthorityUserManager.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Authority/AuthorityAttribute.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Authority/AuthorityAttribute.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Authority/AuthorityGroup.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Authority/AuthorityGroup.cs
Normal file → Executable file
16
DotBased.AspNet.Authority/Models/Authority/AuthorityRole.cs
Normal file → Executable file
16
DotBased.AspNet.Authority/Models/Authority/AuthorityRole.cs
Normal file → Executable file
@@ -1,25 +1,19 @@
|
||||
namespace DotBased.AspNet.Authority.Models.Authority;
|
||||
|
||||
public abstract class AuthorityRole
|
||||
public abstract class AuthorityRole()
|
||||
{
|
||||
public AuthorityRole(string name) : this()
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public AuthorityRole()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
CreatedDate = DateTime.Now;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public long Version { get; set; }
|
||||
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public DateTime CreatedDate { get; set; } = DateTime.Now;
|
||||
|
||||
public override string ToString() => Name ?? string.Empty;
|
||||
}
|
16
DotBased.AspNet.Authority/Models/Authority/AuthorityUser.cs
Normal file → Executable file
16
DotBased.AspNet.Authority/Models/Authority/AuthorityUser.cs
Normal file → Executable file
@@ -2,21 +2,15 @@ using DotBased.AspNet.Authority.Attributes;
|
||||
|
||||
namespace DotBased.AspNet.Authority.Models.Authority;
|
||||
|
||||
public class AuthorityUser
|
||||
public class AuthorityUser()
|
||||
{
|
||||
public AuthorityUser(string userName) : this()
|
||||
{
|
||||
UserName = userName;
|
||||
}
|
||||
|
||||
public AuthorityUser()
|
||||
{
|
||||
Id = Guid.NewGuid();
|
||||
CreatedDate = DateTime.Now;
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public bool Confirmed { get; set; }
|
||||
@@ -29,7 +23,7 @@ public class AuthorityUser
|
||||
|
||||
public string? PasswordHash { get; set; }
|
||||
|
||||
public DateTime CreatedDate { get; set; }
|
||||
public DateTime CreatedDate { get; set; } = DateTime.Now;
|
||||
|
||||
public bool TwoFactorEnabled { get; set; }
|
||||
|
||||
|
0
DotBased.AspNet.Authority/Models/AuthorityResult.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/AuthorityResult.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/AuthorityOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/AuthorityOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/ListOption.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/ListOption.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/LockdownOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/LockdownOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/LockoutOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/LockoutOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/PasswordOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/PasswordOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/ProviderOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/ProviderOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/RepositoryOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/RepositoryOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/SignInOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/SignInOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/UserOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Options/UserOptions.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Validation/ValidationError.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Validation/ValidationError.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Validation/ValidationResult.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Models/Validation/ValidationResult.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IAttributeRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IAttributeRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IGroupRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IGroupRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IRoleRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IRoleRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IUserRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Repositories/IUserRepository.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/IPasswordValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/IPasswordValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/IUserValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/IUserValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/PasswordEqualsValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/PasswordEqualsValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/PasswordOptionsValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/PasswordOptionsValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/UserValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Validators/UserValidator.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IEmailVerifier.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IEmailVerifier.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IPhoneNumberVerifier.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IPhoneNumberVerifier.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IUserVerifier.cs
Normal file → Executable file
0
DotBased.AspNet.Authority/Verifiers/IUserVerifier.cs
Normal file → Executable file
Reference in New Issue
Block a user