[feature] 建立鉴权项目结构
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace SiteManagementSystem_SoftwareEngineering_.Model
|
||||
{
|
||||
public class ApiResponse : OkObjectResult
|
||||
{
|
||||
private ApiResponse(int code, string message, object? data)
|
||||
: base(new ResponseModel(code, message, data)) { }
|
||||
|
||||
public static ApiResponse Success(string message = "", object? data = null) =>
|
||||
new ApiResponse(200, message, data);
|
||||
public static ApiResponse Forbidden(string message = "", object? data = null) =>
|
||||
new ApiResponse(403, message, data);
|
||||
public static ApiResponse Fail(string message = "", object? data = null) =>
|
||||
new ApiResponse(500, message, data);
|
||||
}
|
||||
|
||||
file class ResponseModel
|
||||
{
|
||||
public int Code { get; set; }
|
||||
public string Message { get; set; }
|
||||
public object? Data { get; set; }
|
||||
|
||||
public ResponseModel(int code, string message, object? data)
|
||||
{
|
||||
Code = code;
|
||||
Message = message;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace IwutMail.Model
|
||||
{
|
||||
public class SecretConfig
|
||||
{
|
||||
public string HashSalt { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace SiteManagementSystem_SoftwareEngineering_.Model
|
||||
{
|
||||
public class TokenFactoryConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// AccessToken有效期(分钟)
|
||||
/// </summary>
|
||||
public int AccessTokenExpire { get; set; } = 60;
|
||||
|
||||
/// <summary>
|
||||
/// RefreshToken有效期(分钟)
|
||||
/// </summary>
|
||||
public int RefreshTokenExpire { get; set; } = 10080;
|
||||
|
||||
/// <summary>
|
||||
/// 在RefreshToken过期前多久自动刷新RefreshToken
|
||||
/// </summary>
|
||||
public int RefreshTokenBefore { get; set; } = 1440;
|
||||
|
||||
public string Issuer { get; set; } = null!;
|
||||
|
||||
public string Audience { get; set; } = null!;
|
||||
|
||||
public string SigningKey { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using SiteManagementSystem_SoftwareEngineering_.Entity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SiteManagementSystem_SoftwareEngineering_.Model
|
||||
{
|
||||
public class UserModel
|
||||
{
|
||||
public string RoleName { get; set; } = null!;
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string Name { get; set; } = null!;
|
||||
[Required]
|
||||
[StringLength(50)]
|
||||
public string Secret { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user