Fixed #2810. Do not warn about password for internally generated no auth user when just system account assigned to non-default.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2022-01-21 10:09:10 -08:00
parent dcadf6643a
commit ae43b24be4
2 changed files with 9 additions and 6 deletions

View File

@@ -171,16 +171,19 @@ func (p *Permissions) clone() *Permissions {
// Lock is assumed held.
func (s *Server) checkAuthforWarnings() {
warn := false
if s.opts.Password != "" && !isBcrypt(s.opts.Password) {
if s.opts.Password != _EMPTY_ && !isBcrypt(s.opts.Password) {
warn = true
}
for _, u := range s.users {
// Skip warn if using TLS certs based auth
// unless a password has been left in the config.
if u.Password == "" && s.opts.TLSMap {
if u.Password == _EMPTY_ && s.opts.TLSMap {
continue
}
// Check if this is our internal sys client created on the fly.
if s.sysAccOnlyNoAuthUser != _EMPTY_ && u.Username == s.sysAccOnlyNoAuthUser {
continue
}
if !isBcrypt(u.Password) {
warn = true
break
@@ -1142,7 +1145,7 @@ func validateAllowedConnectionTypes(m map[string]struct{}) error {
}
func validateNoAuthUser(o *Options, noAuthUser string) error {
if noAuthUser == "" {
if noAuthUser == _EMPTY_ {
return nil
}
if len(o.TrustedOperators) > 0 {

View File

@@ -663,7 +663,7 @@ func configureSystemAccount(o *Options, m map[string]interface{}) (retErr error)
// or was present but set to false.
func (o *Options) ProcessConfigFile(configFile string) error {
o.ConfigFile = configFile
if configFile == "" {
if configFile == _EMPTY_ {
return nil
}
m, err := conf.ParseFileWithChecks(configFile)
@@ -1018,7 +1018,7 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error
}
}
// In case "system_account" is defined as well, it takes precedence
if o.SystemAccount == "" {
if o.SystemAccount == _EMPTY_ {
o.SystemAccount = o.TrustedOperators[0].SystemAccount
}
}