Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-30 22:06:11 +01:00

Consider local domain as valid email domain

Don't modify the user generated allow list but do an additional check whether the email domain is the same as the setting.AppURL FQDN Hostname.
This commit is contained in:
patdyn 2024-09-25 11:48:45 +02:00
parent f91849bc9b
commit c6335fda79
2 changed files with 12 additions and 1 deletions

View file

@ -498,5 +498,5 @@ func IsEmailDomainAllowed(email string) bool {
return !validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, email)
}
return validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email)
return validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email) || validation.IsLocalEmailDomain(email)
}

View file

@ -73,6 +73,17 @@ func IsEmailDomainListed(globs []glob.Glob, email string) bool {
return false
}
func IsLocalEmailDomain(email string) bool {
localFqdn, err := url.ParseRequestURI(setting.AppURL)
if err != nil {
return false
}
mailDomain := strings.Split(email, "@")[1]
return mailDomain == localFqdn.Hostname()
}
// IsAPIURL checks if URL is current Gitea instance API URL
func IsAPIURL(uri string) bool {
return strings.HasPrefix(strings.ToLower(uri), strings.ToLower(setting.AppURL+"api"))