Compare commits

..

No commits in common. "de656cc2e861b3a95df2a00ac90bcf0ba03e18c6" and "03daea46e78dfa97d3e4f85fa8035fef5c5ed446" have entirely different histories.

18 changed files with 3 additions and 209 deletions

View File

@ -11,7 +11,7 @@ using Serilog;
using ILogger = Serilog.ILogger; using ILogger = Serilog.ILogger;
var serilogLogger = SetupSerilog(); var serilogLogger = SetupSerilog();
LogService.AddLogAdapter(new BasedSerilogAdapter(serilogLogger)); LogService.AddLogAdapter(new SerilogAdapter(serilogLogger));
var logger = LogService.RegisterLogger(typeof(Program)); var logger = LogService.RegisterLogger(typeof(Program));
logger.Information("Whoah... Hi!"); logger.Information("Whoah... Hi!");
@ -24,6 +24,6 @@ ILogger SetupSerilog()
{ {
var logConfig = new LoggerConfiguration() var logConfig = new LoggerConfiguration()
.MinimumLevel.Verbose() .MinimumLevel.Verbose()
.WriteTo.Console(outputTemplate: BasedSerilog.OutputTemplate); .WriteTo.Console(outputTemplate: SerilogAdapter.SampleTemplate);
return logConfig.CreateLogger(); return logConfig.CreateLogger();
} }

View File

@ -1,6 +0,0 @@
namespace DotBased.ASP.Auth;
public class AuthService
{
}

View File

@ -1,18 +0,0 @@
namespace DotBased.ASP.Auth;
public class BasedAuthConfiguration
{
/// <summary>
/// Allow users to registrate a user account.
/// </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.
public string LoginPath { get; set; } = string.Empty;
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; }
}

View File

@ -1,20 +0,0 @@
using DotBased.Logging;
using Microsoft.AspNetCore.Components.Authorization;
namespace DotBased.ASP.Auth;
public class BasedAuthenticationStateProvider : AuthenticationStateProvider
{
public BasedAuthenticationStateProvider()
{
_logger = LogService.RegisterLogger(typeof(BasedAuthenticationStateProvider));
}
private ILogger _logger;
public override Task<AuthenticationState> GetAuthenticationStateAsync()
{
throw new NotImplementedException();
}
}

View File

@ -1,6 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Auth;
public class AuthenticationStateModel
{
}

View File

@ -1,8 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Auth;
public class PermissionModel
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Permission { get; set; } = string.Empty;
}

View File

@ -1,9 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Auth;
public class RoleModel
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public List<PermissionModel> Permissions { get; set; } = [];
}

View File

@ -1,8 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Identity;
public class GroupItemModel
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}

View File

@ -1,11 +0,0 @@
using DotBased.ASP.Auth.Domains.Auth;
namespace DotBased.ASP.Auth.Domains.Identity;
public class GroupModel
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public List<RoleModel> Roles { get; set; } = [];
}

View File

@ -1,10 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Identity;
public class UserItemModel
{
public string Id { get; set; } = string.Empty;
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string FamilyName { get; set; } = string.Empty;
}

View File

@ -1,14 +0,0 @@
namespace DotBased.ASP.Auth.Domains.Identity;
public class UserModel
{
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string FamilyName { get; set; } = string.Empty;
public string Id { get; set; } = Guid.NewGuid().ToString();
public string PasswordHash { get; set; } = string.Empty;
public string[] GroupIds { get; set; } = Array.Empty<string>();
public string[] Roles { get; set; } = Array.Empty<string>();
}

View File

@ -1,8 +0,0 @@
namespace DotBased.ASP.Auth.Domains;
public class LoginModel
{
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}

View File

@ -1,10 +0,0 @@
namespace DotBased.ASP.Auth.Domains;
public class RegisterModel
{
public string UserName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string FamilyName { get; set; } = string.Empty;
}

View File

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DotBased\DotBased.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.6" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

View File

@ -1,13 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.DependencyInjection;
namespace DotBased.ASP.Auth;
public static class DotBasedASPAuth
{
public static void UseBasedAuth(this WebApplicationBuilder builder, BasedAuthConfiguration configuration)
{
builder.Services.AddScoped<AuthenticationStateProvider, BasedAuthenticationStateProvider>();
}
}

View File

@ -1,38 +0,0 @@
using DotBased.ASP.Auth.Domains.Auth;
using DotBased.ASP.Auth.Domains.Identity;
namespace DotBased.ASP.Auth;
public interface IAuthDataProvider
{
/*
* Identity
*/
// User
public Task<Result> CreateUserAsync(UserModel user);
public Task<Result> UpdateUserAsync(UserModel user);
public Task<Result> DeleteUserAsync(UserModel user);
public Task<Result<UserModel>> GetUserAsync(string id, string email, string username);
public Task<ListResult<UserItemModel>> GetUsersAsync(int start = 0, int amount = 30, string search = "");
// Group
public Task<Result> CreateGroupAsync(GroupModel group);
public Task<Result> UpdateGroupAsync(GroupModel group);
public Task<Result> DeleteGroupAsync(GroupModel group);
public Task<Result<GroupModel>> GetGroupAsync(string id);
public Task<ListResult<GroupItemModel>> GetGroupsAsync(int start = 0, int amount = 30, string search = "");
/*
* Auth
*/
// AuthenticationState
public Task<Result> CreateAuthenticationStateAsync(AuthenticationStateModel authenticationState);
public Task<Result> UpdateAuthenticationStateAsync(AuthenticationStateModel authenticationState);
public Task<Result> DeleteAuthenticationStateAsync(AuthenticationStateModel authenticationState);
public Task<Result<AuthenticationStateModel>> GetAuthenticationStateAsync(string id);
// Authorization
}

View File

@ -8,8 +8,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.Logging.Serilog",
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{2156FB93-C252-4B33-8A0C-73C82FABB163}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{2156FB93-C252-4B33-8A0C-73C82FABB163}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotBased.ASP.Auth", "DotBased.ASP.Auth\DotBased.ASP.Auth.csproj", "{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -28,13 +26,8 @@ Global
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Release|Any CPU.Build.0 = Release|Any CPU {EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC}.Release|Any CPU.Build.0 = Release|Any CPU
{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC} = {2156FB93-C252-4B33-8A0C-73C82FABB163} {EBBDAF9A-BFC7-4BDC-8C51-0501B59A1DDC} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
{CBD4111D-F1CA-466A-AC73-9EAB7F235B3D} = {2156FB93-C252-4B33-8A0C-73C82FABB163}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -8,7 +8,7 @@ namespace DotBased.Logging;
/// </summary> /// </summary>
public static class LogService public static class LogService
{ {
// TODO: Future: add middlewares and changeable log processor // TODO: Future: add middlewares and chanagable log processor
static LogService() static LogService()
{ {
Options = new LogOptions(); Options = new LogOptions();