修改接口

This commit is contained in:
2025-10-16 15:21:52 +08:00
parent 82220ce0b8
commit dd398c1c32
274 changed files with 22777 additions and 22905 deletions

View File

@@ -2,104 +2,42 @@ using System.ComponentModel.DataAnnotations;
namespace FutureMailAPI.DTOs
{
public class OAuthAuthorizationRequestDto
public class OAuthLoginRequestDto
{
[Required]
public string ResponseType { get; set; } = "code"; // code for authorization code flow
[Required]
[Required(ErrorMessage = "客户端ID是必填项")]
public string ClientId { get; set; } = string.Empty;
[Required]
public string RedirectUri { get; set; } = string.Empty;
[Required(ErrorMessage = "客户端密钥是必填项")]
public string ClientSecret { get; set; } = string.Empty;
public string Scope { get; set; } = "read write"; // Default scopes
[Required(ErrorMessage = "用户名或邮箱是必填项")]
public string Username { get; set; } = string.Empty;
public string State { get; set; } = string.Empty; // CSRF protection
}
public class OAuthTokenRequestDto
{
[Required]
public string GrantType { get; set; } = string.Empty; // authorization_code, refresh_token, client_credentials, password
[Required(ErrorMessage = "密码是必填项")]
public string Password { get; set; } = string.Empty;
public string Code { get; set; } = string.Empty; // For authorization_code grant
public string RefreshToken { get; set; } = string.Empty; // For refresh_token grant
public string Username { get; set; } = string.Empty; // For password grant
public string Password { get; set; } = string.Empty; // For password grant
[Required]
public string ClientId { get; set; } = string.Empty;
public string ClientSecret { get; set; } = string.Empty; // Optional for public clients
public string RedirectUri { get; set; } = string.Empty; // Required for authorization_code grant
public string Scope { get; set; } = string.Empty; // Optional, defaults to requested scopes
public string? Scope { get; set; }
}
public class OAuthTokenResponseDto
{
public string AccessToken { get; set; } = string.Empty;
public string TokenType { get; set; } = "Bearer";
public int ExpiresIn { get; set; } // Seconds until expiration
public string RefreshToken { get; set; } = string.Empty;
public string Scope { get; set; } = string.Empty;
public string TokenType { get; set; } = "Bearer";
public int ExpiresIn { get; set; }
public string? Scope { get; set; }
public UserResponseDto User { get; set; } = new();
}
public class OAuthAuthorizationResponseDto
public class OAuthRefreshTokenRequestDto
{
public string Code { get; set; } = string.Empty;
public string State { get; set; } = string.Empty;
}
public class OAuthClientDto
{
public int Id { get; set; }
public string ClientId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string[] RedirectUris { get; set; } = Array.Empty<string>();
public string[] Scopes { get; set; } = Array.Empty<string>();
public bool IsActive { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
public class OAuthClientCreateDto
{
[Required]
[StringLength(100)]
public string Name { get; set; } = string.Empty;
[Required(ErrorMessage = "刷新令牌是必填项")]
public string RefreshToken { get; set; } = string.Empty;
[Required]
public string[] RedirectUris { get; set; } = Array.Empty<string>();
[Required]
public string[] Scopes { get; set; } = Array.Empty<string>();
}
public class OAuthClientSecretDto
{
[Required(ErrorMessage = "客户端ID是必填项")]
public string ClientId { get; set; } = string.Empty;
[Required(ErrorMessage = "客户端密钥是必填项")]
public string ClientSecret { get; set; } = string.Empty;
}
public class OAuthLoginDto
{
[Required]
public string UsernameOrEmail { get; set; } = string.Empty;
[Required]
public string Password { get; set; } = string.Empty;
[Required]
public string ClientId { get; set; } = string.Empty;
public string ClientSecret { get; set; } = string.Empty; // Optional for public clients
public string Scope { get; set; } = "read write"; // Default scopes
}
}