chore: initial project import
This commit is contained in:
commit
3fc4e5ca53
347 files changed
+56172
No files matched your search
@@ -0,0 +1,29 @@
|
||||
namespace Monitor.Backend.Application;
|
||||
|
||||
public enum PrincipalKind
|
||||
{
|
||||
Anonymous,
|
||||
Session,
|
||||
Token,
|
||||
}
|
||||
|
||||
/// <summary>访问级别:作用域为 read 的令牌只读,admin 可以管理。</summary>
|
||||
public enum ApiScope
|
||||
{
|
||||
None = 0,
|
||||
Read = 1,
|
||||
Admin = 2,
|
||||
}
|
||||
|
||||
public sealed record Principal(PrincipalKind Kind, ApiScope Scope, string? UserId, string? Username, string? CsrfToken, string? TokenId)
|
||||
{
|
||||
public static Principal Anonymous { get; } = new(PrincipalKind.Anonymous, ApiScope.None, null, null, null, null);
|
||||
|
||||
public bool CanRead => Scope >= ApiScope.Read;
|
||||
|
||||
public bool IsAdmin => Scope >= ApiScope.Admin;
|
||||
}
|
||||
|
||||
public sealed record LoginResult(string SessionToken, string CsrfToken, long ExpiresAtMs, string UserId, string Username);
|
||||
|
||||
public sealed record CreatedApiToken(ApiTokenRecord Record, string Plaintext);
|
||||
Reference in new issue
Block a user