- Added configuration options for Stalwart hosted mail in .env.example. - Updated Docker Compose to include Stalwart service with health checks. - Introduced new API endpoints for managing mail domains and migration projects. - Enhanced Authentik blueprints for user enrollment and post-migration security. - Updated OAuth handling for Google and Microsoft migration processes. - Improved error handling and response structures in the mail API. - Added integration tests for email claiming and migration workflows.
37 lines
811 B
Go
37 lines
811 B
Go
package migration
|
|
|
|
import "strings"
|
|
|
|
const AuthModeOAuth = "oauth"
|
|
const AuthModeGoogleDWD = "google_dwd"
|
|
const AuthModeMicrosoftApp = "microsoft_app"
|
|
|
|
func NormalizeAuthMode(provider, authMode string) string {
|
|
authMode = strings.ToLower(strings.TrimSpace(authMode))
|
|
if authMode == "" {
|
|
return AuthModeOAuth
|
|
}
|
|
provider = strings.ToLower(strings.TrimSpace(provider))
|
|
switch authMode {
|
|
case AuthModeGoogleDWD:
|
|
if provider == "google" {
|
|
return AuthModeGoogleDWD
|
|
}
|
|
case AuthModeMicrosoftApp:
|
|
if provider == "microsoft" {
|
|
return AuthModeMicrosoftApp
|
|
}
|
|
}
|
|
return AuthModeOAuth
|
|
}
|
|
|
|
func UsesUserOAuth(provider, authMode string) bool {
|
|
authMode = NormalizeAuthMode(provider, authMode)
|
|
switch authMode {
|
|
case AuthModeGoogleDWD, AuthModeMicrosoftApp:
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|