mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
ab8f9b0697
This change addresses an issue with the usage of the full sender configuration option in the MAIL FROM SMTP command. If a user includes a name in the sender this shouldn't be sent in the MAIL FROM command, instead we should extract it and use just the email portion. Fixes #2571
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package validator
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
)
|
|
|
|
// ValidateNotifier validates and update notifier configuration.
|
|
func ValidateNotifier(configuration *schema.NotifierConfiguration, validator *schema.StructValidator) {
|
|
if configuration.SMTP == nil && configuration.FileSystem == nil {
|
|
validator.Push(fmt.Errorf(errFmtNotifierNotConfigured))
|
|
|
|
return
|
|
} else if configuration.SMTP != nil && configuration.FileSystem != nil {
|
|
validator.Push(fmt.Errorf(errFmtNotifierMultipleConfigured))
|
|
|
|
return
|
|
}
|
|
|
|
if configuration.FileSystem != nil {
|
|
if configuration.FileSystem.Filename == "" {
|
|
validator.Push(fmt.Errorf(errFmtNotifierFileSystemFileNameNotConfigured))
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
validateSMTPNotifier(configuration.SMTP, validator)
|
|
}
|
|
|
|
func validateSMTPNotifier(configuration *schema.SMTPNotifierConfiguration, validator *schema.StructValidator) {
|
|
if configuration.StartupCheckAddress == "" {
|
|
configuration.StartupCheckAddress = schema.DefaultSMTPNotifierConfiguration.StartupCheckAddress
|
|
}
|
|
|
|
if configuration.Host == "" {
|
|
validator.Push(fmt.Errorf(errFmtNotifierSMTPNotConfigured, "host"))
|
|
}
|
|
|
|
if configuration.Port == 0 {
|
|
validator.Push(fmt.Errorf(errFmtNotifierSMTPNotConfigured, "port"))
|
|
}
|
|
|
|
if configuration.Timeout == 0 {
|
|
configuration.Timeout = schema.DefaultSMTPNotifierConfiguration.Timeout
|
|
}
|
|
|
|
if configuration.Sender.Address == "" {
|
|
validator.Push(fmt.Errorf(errFmtNotifierSMTPNotConfigured, "sender"))
|
|
}
|
|
|
|
if configuration.Subject == "" {
|
|
configuration.Subject = schema.DefaultSMTPNotifierConfiguration.Subject
|
|
}
|
|
|
|
if configuration.Identifier == "" {
|
|
configuration.Identifier = schema.DefaultSMTPNotifierConfiguration.Identifier
|
|
}
|
|
|
|
if configuration.TLS == nil {
|
|
configuration.TLS = schema.DefaultSMTPNotifierConfiguration.TLS
|
|
}
|
|
|
|
if configuration.TLS.ServerName == "" {
|
|
configuration.TLS.ServerName = configuration.Host
|
|
}
|
|
}
|