初始化
This commit is contained in:
105
FutureMailAPI/DTOs/OAuthDTOs.cs
Normal file
105
FutureMailAPI/DTOs/OAuthDTOs.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FutureMailAPI.DTOs
|
||||
{
|
||||
public class OAuthAuthorizationRequestDto
|
||||
{
|
||||
[Required]
|
||||
public string ResponseType { get; set; } = "code"; // code for authorization code flow
|
||||
|
||||
[Required]
|
||||
public string ClientId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string RedirectUri { get; set; } = string.Empty;
|
||||
|
||||
public string Scope { get; set; } = "read write"; // Default scopes
|
||||
|
||||
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
|
||||
|
||||
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 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 class OAuthAuthorizationResponseDto
|
||||
{
|
||||
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]
|
||||
public string[] RedirectUris { get; set; } = Array.Empty<string>();
|
||||
|
||||
[Required]
|
||||
public string[] Scopes { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
|
||||
public class OAuthClientSecretDto
|
||||
{
|
||||
public string ClientId { get; set; } = string.Empty;
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user