[ADD] Base Authority initial commit

This commit is contained in:
max
2024-12-21 15:30:17 +01:00
parent 21675300bb
commit 2361e12847
18 changed files with 155 additions and 30 deletions

View File

@@ -0,0 +1,10 @@
namespace DotBased.AspNet.Authority.Attributes;
/// <summary>
/// Indicates that the property should be protected.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ProtectAttribute : Attribute
{
}

View File

@@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
namespace DotBased.AspNet.Authority;
public class AuthorityBuilder
{
public AuthorityBuilder(IServiceCollection services)
{
Services = services;
}
public IServiceCollection Services { get; }
}

View File

@@ -0,0 +1,11 @@
namespace DotBased.AspNet.Authority;
public static class AuthorityDefaults
{
public static class Scheme
{
public const string AuthenticationScheme = "Authority.Scheme.Authentication";
public const string ExternalScheme = "Authority.Scheme.External";
}
}

View File

@@ -0,0 +1,17 @@
using DotBased.AspNet.Authority.Interfaces;
using Microsoft.Extensions.DependencyInjection;
namespace DotBased.AspNet.Authority;
public static class AuthorityProviderExtensions
{
public static AuthorityBuilder AddAuthorityProvider<TModel>(this IServiceCollection services) where TModel : class
{
return new AuthorityBuilder(services);
}
public static AuthorityBuilder AddAuthorityStore<TStore>(this AuthorityBuilder authorityBuilder) where TStore : IAuthorityRepository
{
return authorityBuilder;
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions">
<HintPath>..\..\..\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\8.0.2\lib\net8.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotBased\DotBased.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Authentication\" />
<Folder Include="Models\Security\" />
<Folder Include="Repositories\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,6 @@
namespace DotBased.AspNet.Authority.Interfaces;
public interface IAttributeRepository
{
}

View File

@@ -0,0 +1,6 @@
namespace DotBased.AspNet.Authority.Interfaces;
public interface IAuthorityRepository
{
}

View File

@@ -0,0 +1,6 @@
namespace DotBased.AspNet.Authority.Interfaces;
public interface IRoleRepository
{
}

View File

@@ -0,0 +1,6 @@
namespace DotBased.AspNet.Authority.Interfaces;
public interface IUserRepository
{
}

View File

@@ -0,0 +1,10 @@
namespace DotBased.AspNet.Authority.Models.Authority;
public class AuthorityUser : AuthorityUserBase<Guid>
{
public AuthorityUser()
{
Id = Guid.NewGuid();
CreatedDate = DateTime.Now;
}
}

View File

@@ -0,0 +1,32 @@
using DotBased.AspNet.Authority.Attributes;
namespace DotBased.AspNet.Authority.Models.Authority;
public abstract class AuthorityUserBase<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; }
public bool Enabled { get; set; }
public bool Locked { get; set; }
public string UserName { get; set; }
public string PasswordHash { get; set; }
public DateTime CreatedDate { get; set; }
public bool TwoFactorEnabled { get; set; }
[Protect]
public string EmailAddress { get; set; }
public bool EmailConfirmed { get; set; }
[Protect]
public string PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace DotBased.AspNet.Authority.Services;
public class AuthorityService
{
}