diff --git a/controller/config/config.go b/controller/config/config.go index aeeea4f7..564af677 100644 --- a/controller/config/config.go +++ b/controller/config/config.go @@ -17,27 +17,27 @@ import ( const ConfigVersion = 3 type Config struct { - V int - Admin *AdminConfig - Bridge *metrics.BridgeConfig - Endpoint *EndpointConfig - Email *emailUi.Config - Limits *limits.Config - Maintenance *MaintenanceConfig - Metrics *metrics.Config - Registration *RegistrationConfig - ResetPassword *ResetPasswordConfig - Store *store.Config - Ziti *zrokEdgeSdk.Config - PasswordRequirements *PaswordRequirementsConfig + V int + Admin *AdminConfig + Bridge *metrics.BridgeConfig + Endpoint *EndpointConfig + Email *emailUi.Config + Limits *limits.Config + Maintenance *MaintenanceConfig + Metrics *metrics.Config + Passwords *PasswordsConfig + Registration *RegistrationConfig + ResetPassword *ResetPasswordConfig + Store *store.Config + Ziti *zrokEdgeSdk.Config } type AdminConfig struct { - Secrets []string `cf:"+secret"` - TouLink string InvitesOpen bool InviteTokenStrategy string InviteTokenContact string + Secrets []string `cf:"+secret"` + TouLink string } type EndpointConfig struct { @@ -45,11 +45,12 @@ type EndpointConfig struct { Port int } -type RegistrationConfig struct { - RegistrationUrlTemplate string +type MaintenanceConfig struct { + ResetPassword *ResetPasswordMaintenanceConfig + Registration *RegistrationMaintenanceConfig } -type PaswordRequirementsConfig struct { +type PasswordsConfig struct { Length int RequireCapital bool RequireNumeric bool @@ -57,13 +58,12 @@ type PaswordRequirementsConfig struct { ValidSpecialCharacters string } -type ResetPasswordConfig struct { - ResetUrlTemplate string +type RegistrationConfig struct { + RegistrationUrlTemplate string } -type MaintenanceConfig struct { - ResetPassword *ResetPasswordMaintenanceConfig - Registration *RegistrationMaintenanceConfig +type ResetPasswordConfig struct { + ResetUrlTemplate string } type RegistrationMaintenanceConfig struct { @@ -81,13 +81,6 @@ type ResetPasswordMaintenanceConfig struct { func DefaultConfig() *Config { return &Config{ Limits: limits.DefaultConfig(), - PasswordRequirements: &PaswordRequirementsConfig{ - Length: 8, - RequireCapital: true, - RequireNumeric: true, - RequireSpecial: true, - ValidSpecialCharacters: `!@$&*_-., "#%'()+/:;<=>?[\]^{|}~`, - }, Maintenance: &MaintenanceConfig{ ResetPassword: &ResetPasswordMaintenanceConfig{ ExpirationTimeout: time.Minute * 15, @@ -100,6 +93,13 @@ func DefaultConfig() *Config { BatchLimit: 500, }, }, + Passwords: &PasswordsConfig{ + Length: 8, + RequireCapital: true, + RequireNumeric: true, + RequireSpecial: true, + ValidSpecialCharacters: `!@$&*_-., "#%'()+/:;<=>?[\]^{|}~`, + }, } } diff --git a/controller/configuration.go b/controller/configuration.go index 66430af1..73ea42ad 100644 --- a/controller/configuration.go +++ b/controller/configuration.go @@ -27,14 +27,14 @@ func (ch *configurationHandler) Handle(_ metadata.ConfigurationParams) middlewar if cfg.Admin != nil { data.TouLink = cfg.Admin.TouLink data.InviteTokenContact = cfg.Admin.InviteTokenContact - } - if cfg.PasswordRequirements != nil { - data.PasswordRequirements = &rest_model_zrok.PasswordRequirements{ - Length: int64(cfg.PasswordRequirements.Length), - RequireCapital: cfg.PasswordRequirements.RequireCapital, - RequireNumeric: cfg.PasswordRequirements.RequireNumeric, - RequireSpecial: cfg.PasswordRequirements.RequireSpecial, - ValidSpecialCharacters: cfg.PasswordRequirements.ValidSpecialCharacters, + if cfg.Passwords != nil { + data.PasswordRequirements = &rest_model_zrok.PasswordRequirements{ + Length: int64(cfg.Passwords.Length), + RequireCapital: cfg.Passwords.RequireCapital, + RequireNumeric: cfg.Passwords.RequireNumeric, + RequireSpecial: cfg.Passwords.RequireSpecial, + ValidSpecialCharacters: cfg.Passwords.ValidSpecialCharacters, + } } } return metadata.NewConfigurationOK().WithPayload(data) diff --git a/controller/util.go b/controller/util.go index 9d934df3..c490fde2 100644 --- a/controller/util.go +++ b/controller/util.go @@ -92,21 +92,21 @@ func proxyUrl(shrToken, template string) string { } func validatePassword(cfg *config.Config, password string) error { - if cfg.PasswordRequirements.Length > len(password) { - return fmt.Errorf("password length: expected (%d), got (%d)", cfg.PasswordRequirements.Length, len(password)) + if cfg.Passwords.Length > len(password) { + return fmt.Errorf("password length: expected (%d), got (%d)", cfg.Passwords.Length, len(password)) } - if cfg.PasswordRequirements.RequireCapital { + if cfg.Passwords.RequireCapital { if !hasCapital(password) { return fmt.Errorf("password requires capital, found none") } } - if cfg.PasswordRequirements.RequireNumeric { + if cfg.Passwords.RequireNumeric { if !hasNumeric(password) { return fmt.Errorf("password requires numeric, found none") } } - if cfg.PasswordRequirements.RequireSpecial { - if !strings.ContainsAny(password, cfg.PasswordRequirements.ValidSpecialCharacters) { + if cfg.Passwords.RequireSpecial { + if !strings.ContainsAny(password, cfg.Passwords.ValidSpecialCharacters) { return fmt.Errorf("password requires special character, found none") } } diff --git a/ui/src/components/password.js b/ui/src/components/password.js index 8e67f421..4b708e50 100644 --- a/ui/src/components/password.js +++ b/ui/src/components/password.js @@ -33,7 +33,7 @@ const PasswordForm = (props) => { return; } } - if (confirm != password) { + if (confirm !== password) { props.setMessage(passwordMismatchMessage) return; }