- Added JWT configuration to appsettings.json for secure token handling. - Updated config.json to include OAuth provider details for Microsoft, Google, and PocketId. - Added Microsoft icon SVG for UI representation. - Refactored app.config.ts to use a custom AuthInterceptor for managing access tokens. - Enhanced auth route guard to handle asynchronous authentication checks. - Created new auth models for structured request and response handling. - Developed a callback component to manage user login states and transitions. - Updated side-login component to support multiple OAuth providers with loading states. - Implemented authentication service methods for handling OAuth login flows and token management. - Added error handling and user feedback for authentication processes.
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace Api.Models.DTOs
|
|
{
|
|
public class AuthenticateRequest
|
|
{
|
|
[Required]
|
|
public string IdToken { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Provider { get; set; } = string.Empty; // "Microsoft", "Google", "PocketId"
|
|
|
|
/// <summary>
|
|
/// Optional access token for API calls (e.g., Microsoft Graph)
|
|
/// </summary>
|
|
public string? AccessToken { get; set; }
|
|
}
|
|
|
|
public class AuthenticateResponse
|
|
{
|
|
public string AccessToken { get; set; } = string.Empty;
|
|
public DateTime ExpiresAt { get; set; }
|
|
public UserProfile User { get; set; } = null!;
|
|
public bool IsNewUser { get; set; }
|
|
}
|
|
|
|
public class UserProfile
|
|
{
|
|
public int Id { get; set; }
|
|
public string Email { get; set; } = string.Empty;
|
|
public string? FirstName { get; set; }
|
|
public string? LastName { get; set; }
|
|
public string? ProfilePictureUrl { get; set; }
|
|
public DateTime CreatedAt { get; set; }
|
|
public DateTime? LastLoginAt { get; set; }
|
|
public List<string> Providers { get; set; } = new List<string>();
|
|
}
|
|
|
|
public class JwtSettings
|
|
{
|
|
public string SecretKey { get; set; } = string.Empty;
|
|
public string Issuer { get; set; } = string.Empty;
|
|
public string Audience { get; set; } = string.Empty;
|
|
public int ExpirationMinutes { get; set; } = 60;
|
|
}
|
|
|
|
public class OAuthProviderSettings
|
|
{
|
|
public Dictionary<string, ProviderConfig> Providers { get; set; } = new Dictionary<string, ProviderConfig>();
|
|
}
|
|
|
|
public class ProviderConfig
|
|
{
|
|
public string Authority { get; set; } = string.Empty;
|
|
public string ClientId { get; set; } = string.Empty;
|
|
public string? ClientSecret { get; set; }
|
|
public List<string> ValidAudiences { get; set; } = new List<string>();
|
|
}
|
|
} |