[CHANGE] Building data structure

This commit is contained in:
max 2025-01-27 01:21:09 +01:00
parent 3ccd3106c1
commit c27890a31f
118 changed files with 356 additions and 51 deletions

0
Blazor.Wasm/App.razor Normal file → Executable file
View File

0
Blazor.Wasm/Blazor.Wasm.csproj Normal file → Executable file
View File

0
Blazor.Wasm/Layout/MainLayout.razor Normal file → Executable file
View File

0
Blazor.Wasm/Layout/MainLayout.razor.css Normal file → Executable file
View File

0
Blazor.Wasm/Layout/NavMenu.razor Normal file → Executable file
View File

0
Blazor.Wasm/Layout/NavMenu.razor.css Normal file → Executable file
View File

0
Blazor.Wasm/Pages/Counter.razor Normal file → Executable file
View File

0
Blazor.Wasm/Pages/Home.razor Normal file → Executable file
View File

0
Blazor.Wasm/Pages/Weather.razor Normal file → Executable file
View File

0
Blazor.Wasm/Program.cs Normal file → Executable file
View File

0
Blazor.Wasm/Properties/launchSettings.json Normal file → Executable file
View File

0
Blazor.Wasm/_Imports.razor Normal file → Executable file
View File

0
Blazor.Wasm/wwwroot/css/app.css Normal file → Executable file
View File

0
Blazor.Wasm/wwwroot/css/bootstrap/bootstrap.min.css vendored Normal file → Executable file
View File

View File

0
Blazor.Wasm/wwwroot/favicon.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

0
Blazor.Wasm/wwwroot/icon-192.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

0
Blazor.Wasm/wwwroot/index.html Normal file → Executable file
View File

0
Blazor.Wasm/wwwroot/sample-data/weather.json Normal file → Executable file
View File

0
DotBased.ASP.Auth/AuthDataCache.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/AuthenticationService.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/BasedAuthConfiguration.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/BasedAuthDefaults.cs Normal file → Executable file
View File

View File

View File

0
DotBased.ASP.Auth/Domains/Auth/PermissionModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/Auth/RoleModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/Identity/GroupItemModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/Identity/GroupModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/Identity/UserItemModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/Identity/UserModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/LoginModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/Domains/RegisterModel.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/DotBased.ASP.Auth.csproj Normal file → Executable file
View File

0
DotBased.ASP.Auth/DotBasedAuthDependencyInjection.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/IAuthDataRepository.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/ISessionStateProvider.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/MemoryAuthDataRepository.cs Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

0
DotBased.ASP.Auth/SecurityManager.cs Normal file → Executable file
View File

0
DotBased.ASP.Auth/SecurityService.cs Normal file → Executable file
View File

View File

0
DotBased.AspNet.Authority/AuthorityBuilder.cs Normal file → Executable file
View File

0
DotBased.AspNet.Authority/AuthorityDefaults.cs Normal file → Executable file
View File

View File

0
DotBased.AspNet.Authority/Crypto/Cryptographer.cs Normal file → Executable file
View File

0
DotBased.AspNet.Authority/Crypto/ICryptographer.cs Normal file → Executable file
View File

0
DotBased.AspNet.Authority/Crypto/IPasswordHasher.cs Normal file → Executable file
View File

0
DotBased.AspNet.Authority/Crypto/PasswordHasher.cs Normal file → Executable file
View File

View File

View 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
*/
}

39
DotBased.AspNet.Authority/Managers/AuthorityManager.cs Normal file → Executable file
View File

@ -9,35 +9,24 @@ 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 IServiceProvider Services { get; }
public AuthorityOptions Options { get; }
public ICryptographer Cryptographer { get; }
public IUserRepository UserRepository { get; } = userRepository;
public IRoleRepository RoleRepository { get; } = roleRepository;
public IUserRepository UserRepository { get; }
public IRoleRepository RoleRepository { get; }
public IPasswordHasher PasswordHasher { get; }
public IPasswordHasher PasswordHasher { get; } = passwordHasher;
public IEnumerable<IPasswordValidator> PasswordValidators { get; } = [];
public IEnumerable<IUserValidator> UserValidators { get; } = [];

View 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!");
}
}

View File

View File

View File

View 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;
}

View File

@ -2,20 +2,14 @@ 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; }
@ -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
View File

View File

0
DotBased.AspNet.Authority/Models/Options/ListOption.cs Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

0
DotBased.AspNet.Authority/Validators/IUserValidator.cs Normal file → Executable file
View File

View File

View File

0
DotBased.AspNet.Authority/Validators/UserValidator.cs Normal file → Executable file
View File

0
DotBased.AspNet.Authority/Verifiers/IEmailVerifier.cs Normal file → Executable file
View File

View File

0
DotBased.AspNet.Authority/Verifiers/IUserVerifier.cs Normal file → Executable file
View File

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DotBased\DotBased.csproj" />
</ItemGroup>
</Project>

0
DotBased.Logging.MEL/BasedLogger.cs Normal file → Executable file
View File

0
DotBased.Logging.MEL/BasedLoggerProvider.cs Normal file → Executable file
View File

0
DotBased.Logging.MEL/DotBased.Logging.MEL.csproj Normal file → Executable file
View File

0
DotBased.Logging.MEL/LoggerBuilderExtensions.cs Normal file → Executable file
View File

0
DotBased.Logging.Serilog/BasedSerilog.cs Normal file → Executable file
View File

0
DotBased.Logging.Serilog/BasedSerilogEnricher.cs Normal file → Executable file
View File

View File

@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNet", "AspNet", "{624E7B
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.AspNet.Authority", "DotBased.AspNet.Authority\DotBased.AspNet.Authority.csproj", "{A3ADC9AF-39B7-4EC4-8022-946118A8C322}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.Data", "DotBased.Data\DotBased.Data.csproj", "{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -60,6 +62,10 @@ Global
{A3ADC9AF-39B7-4EC4-8022-946118A8C322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3ADC9AF-39B7-4EC4-8022-946118A8C322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3ADC9AF-39B7-4EC4-8022-946118A8C322}.Release|Any CPU.Build.0 = Release|Any CPU
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
@ -69,5 +75,6 @@ Global
{AC8343A5-7953-4E1D-A926-406BE4D7E819} = {DBDB4538-85D4-45AC-9E0A-A684467AEABA}
{624E7B11-8A18-46E5-AB1F-6AF6097F9D4D} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
{A3ADC9AF-39B7-4EC4-8022-946118A8C322} = {624E7B11-8A18-46E5-AB1F-6AF6097F9D4D}
{2DF9FEEF-5A60-4B41-9B5F-F883DCE33EF4} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
EndGlobalSection
EndGlobal

0
DotBased/Objects/DbObjectAttribute.cs Normal file → Executable file
View File

0
DotBased/Objects/IObjectAttribute.cs Normal file → Executable file
View File

0
DotBased/Objects/ObjectAttribute.cs Normal file → Executable file
View File

0
TestWebApi/Program.cs Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More