diff --git a/src/core/DigitalData.MessagingService.Domain/Entities/EmailAccount.cs b/src/core/DigitalData.MessagingService.Domain/Entities/EmailAccount.cs index 691229e..b7e88b3 100644 --- a/src/core/DigitalData.MessagingService.Domain/Entities/EmailAccount.cs +++ b/src/core/DigitalData.MessagingService.Domain/Entities/EmailAccount.cs @@ -103,18 +103,38 @@ public class EmailAccount /// /// OAuth2 client secret (required when is true). + /// For Microsoft: the app registration client secret value from Azure Portal. + /// For Google: the client secret from Google Cloud Console credentials JSON. /// [MaxLength(512)] [Column("OAUTH2_CLIENT_SECRET", TypeName = "nvarchar(512)")] public string? OAuth2ClientSecret { get; set; } + /// + /// OAuth2 refresh token (Google only). + /// Obtained once via the OAuth2 authorization flow (e.g. OAuth Playground). + /// Used to exchange for short-lived access tokens without user interaction. + /// Leave empty for Microsoft — MSAL handles token refresh internally. + /// + [MaxLength(1024)] + [Column("OAUTH2_REFRESH_TOKEN", TypeName = "nvarchar(1024)")] + public string? OAuth2RefreshToken { get; set; } + /// /// OAuth2 tenant ID (e.g. for Microsoft 365: tenant GUID or "common"). + /// Not required for Google — leave empty. /// [MaxLength(256)] [Column("OAUTH2_TENANT_ID", TypeName = "nvarchar(256)")] public string? OAuth2TenantId { get; set; } + /// + /// Identifies which OAuth2 identity provider to use when is true. + /// Determines which token acquisition strategy is applied. + /// + [Column("OAUTH2_PROVIDER", TypeName = "int")] + public OAuth2Provider OAuth2Provider { get; set; } = OAuth2Provider.None; + /// /// The protocol used to receive (sync) incoming emails. /// When set to , this account is send-only and will be skipped by the sync worker. diff --git a/src/core/DigitalData.MessagingService.Domain/Enums/OAuth2Provider.cs b/src/core/DigitalData.MessagingService.Domain/Enums/OAuth2Provider.cs new file mode 100644 index 0000000..6d0f121 --- /dev/null +++ b/src/core/DigitalData.MessagingService.Domain/Enums/OAuth2Provider.cs @@ -0,0 +1,29 @@ +namespace DigitalData.MessagingService.Domain.Enums; + +/// +/// Identifies the OAuth2 identity provider used to acquire access tokens. +/// Only relevant when UseOAuth2 = true. +/// +public enum OAuth2Provider +{ + /// + /// No OAuth2 provider — account uses plain username/password authentication. + /// + None = 0, + + /// + /// Microsoft identity platform (Azure AD / Microsoft 365 / Exchange Online). + /// Uses MSAL with the client credentials flow against + /// https://login.microsoftonline.com/{tenant}. + /// Requires OAuth2ClientId, OAuth2ClientSecret and OAuth2TenantId. + /// + Microsoft = 1, + + /// + /// Google identity platform (Gmail / Google Workspace). + /// Uses the service-account or OAuth2 client credentials flow against + /// https://oauth2.googleapis.com/token. + /// Requires OAuth2ClientId and OAuth2ClientSecret. + /// + Google = 2, +}