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:
parent
f91849bc9b
commit
c6335fda79
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in a new issue