Commit cb2259cf authored by ale's avatar ale

Add a list of forbidden domains that can't be created

parent fcd599da
Pipeline #5695 passed with stages
in 4 minutes and 47 seconds
......@@ -34,6 +34,8 @@ type ValidationConfig struct {
ForbiddenUsernamesFile string `yaml:"forbidden_usernames_file"`
ForbiddenPasswords []string `yaml:"forbidden_passwords"`
ForbiddenPasswordsFile string `yaml:"forbidden_passwords_file"`
ForbiddenDomains []string `yaml:"forbidden_domains"`
ForbiddenDomainsFile string `yaml:"forbidden_domains_file"`
AvailableDomains map[string][]string `yaml:"available_domains"`
WebsiteRootDir string `yaml:"website_root_dir"`
MinPasswordLen int `yaml:"min_password_len"`
......@@ -45,6 +47,7 @@ type ValidationConfig struct {
forbiddenUsernames stringSet
forbiddenPasswords stringSet
forbiddenDomains stringSet
}
const (
......@@ -85,6 +88,10 @@ func (c *ValidationConfig) compile() (err error) {
return
}
c.forbiddenPasswords, err = newStringSetFromFileOrList(c.ForbiddenPasswords, c.ForbiddenPasswordsFile)
if err != nil {
return
}
c.forbiddenDomains, err = newStringSetFromFileOrList(c.ForbiddenDomains, c.ForbiddenDomainsFile)
return
}
......@@ -678,6 +685,7 @@ func (v *validationContext) validDomainResource() ResourceValidatorFunc {
domainValidator := allOf(
minLength(6),
validDomainName,
notInSet(v.config.forbiddenDomains),
)
newDomainValidator := allOf(
domainValidator,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment