refactor: distribute the domain folder
This commit is contained in:
Endpoint
Common
Configuration
Controllers
Security
Common
Domain
Model
OAuth2
ViewModel
Services
29
Security/Common/Model/CookieOptions.cs
Normal file
29
Security/Common/Model/CookieOptions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
|
||||
namespace Mirea.Api.Security.Common.Model;
|
||||
|
||||
public class CookieOptions
|
||||
{
|
||||
public required string Domain { get; set; }
|
||||
public required string Path { get; set; }
|
||||
|
||||
internal void SetCookie(HttpContext context, string name, string value, DateTimeOffset? expires = null)
|
||||
{
|
||||
var cookieOptions = new Microsoft.AspNetCore.Http.CookieOptions
|
||||
{
|
||||
Expires = expires,
|
||||
Path = Path,
|
||||
Domain = Domain,
|
||||
HttpOnly = true,
|
||||
#if !DEBUG
|
||||
Secure = true
|
||||
#endif
|
||||
};
|
||||
|
||||
context.Response.Cookies.Append(name, value, cookieOptions);
|
||||
}
|
||||
|
||||
internal void DropCookie(HttpContext context, string name) =>
|
||||
SetCookie(context, name, "", DateTimeOffset.MinValue);
|
||||
}
|
15
Security/Common/Model/PasswordPolicy.cs
Normal file
15
Security/Common/Model/PasswordPolicy.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace Mirea.Api.Security.Common.Model;
|
||||
|
||||
public class PasswordPolicy(
|
||||
int minimumLength = 8,
|
||||
bool requireLetter = true,
|
||||
bool requireLettersDifferentCase = true,
|
||||
bool requireDigit = true,
|
||||
bool requireSpecialCharacter = true)
|
||||
{
|
||||
public int MinimumLength { get; set; } = minimumLength;
|
||||
public bool RequireLetter { get; set; } = requireLetter;
|
||||
public bool RequireLettersDifferentCase { get; set; } = requireLettersDifferentCase;
|
||||
public bool RequireDigit { get; set; } = requireDigit;
|
||||
public bool RequireSpecialCharacter { get; set; } = requireSpecialCharacter;
|
||||
}
|
7
Security/Common/Model/TwoFactorAuthenticator.cs
Normal file
7
Security/Common/Model/TwoFactorAuthenticator.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Mirea.Api.Security.Common.Model;
|
||||
|
||||
public enum TwoFactorAuthenticator
|
||||
{
|
||||
None,
|
||||
Totp
|
||||
}
|
16
Security/Common/Model/User.cs
Normal file
16
Security/Common/Model/User.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Mirea.Api.Security.Common.Domain;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Mirea.Api.Security.Common.Model;
|
||||
|
||||
public class User
|
||||
{
|
||||
public required string Id { get; set; }
|
||||
public required string Username { get; set; }
|
||||
public required string Email { get; set; }
|
||||
public required string PasswordHash { get; set; }
|
||||
public required string Salt { get; set; }
|
||||
public required TwoFactorAuthenticator TwoFactorAuthenticator { get; set; }
|
||||
public string? SecondFactorToken { get; set; }
|
||||
public Dictionary<OAuthProvider, OAuthUser>? OAuthProviders { get; set; }
|
||||
}
|
Reference in New Issue
Block a user