Browse Source

keep the passwords in sync

Abhishek Kondur 2 years ago
parent
commit
33ac0bfdb9
2 changed files with 11 additions and 8 deletions
  1. 9 8
      mq/dynsec.go
  2. 2 0
      mq/dynsec_helper.go

+ 9 - 8
mq/dynsec.go

@@ -132,19 +132,20 @@ func encodePasswordToPBKDF2(password string, salt string, iterations int, keyLen
 
 
 // Configure - configures the dynamic initial configuration for MQ
 // Configure - configures the dynamic initial configuration for MQ
 func Configure() error {
 func Configure() error {
+	logger.Log(0, "Configuring MQ...")
 	path := functions.GetNetmakerPath() + ncutils.GetSeparator() + dynamicSecurityFile
 	path := functions.GetNetmakerPath() + ncutils.GetSeparator() + dynamicSecurityFile
-	if logic.CheckIfFileExists(path) {
-		logger.Log(0, "MQ Is Already Configured, Skipping...")
-		return nil
-	}
-	if servercfg.Is_EE {
-		dynConfig.Clients = append(dynConfig.Clients, exporterMQClient)
-		dynConfig.Roles = append(dynConfig.Roles, exporterMQRole)
-	}
+
 	password := servercfg.GetMqAdminPassword()
 	password := servercfg.GetMqAdminPassword()
 	if password == "" {
 	if password == "" {
 		return errors.New("MQ admin password not provided")
 		return errors.New("MQ admin password not provided")
 	}
 	}
+	if logic.CheckIfFileExists(path) {
+		data, err := os.ReadFile(path)
+		if err == nil {
+			json.Unmarshal(data, &dynConfig)
+		}
+	}
+
 	for i, cI := range dynConfig.Clients {
 	for i, cI := range dynConfig.Clients {
 		if cI.Username == mqAdminUserName || cI.Username == mqNetmakerServerUserName {
 		if cI.Username == mqAdminUserName || cI.Username == mqNetmakerServerUserName {
 			salt := logic.RandomString(12)
 			salt := logic.RandomString(12)

+ 2 - 0
mq/dynsec_helper.go

@@ -52,6 +52,7 @@ var (
 					},
 					},
 				},
 				},
 			},
 			},
+			exporterMQClient,
 		},
 		},
 		Roles: []role{
 		Roles: []role{
 			{
 			{
@@ -66,6 +67,7 @@ var (
 				Rolename: NodeRole,
 				Rolename: NodeRole,
 				Acls:     fetchNodeAcls(),
 				Acls:     fetchNodeAcls(),
 			},
 			},
+			exporterMQRole,
 		},
 		},
 		DefaultAcl: defaultAccessAcl{
 		DefaultAcl: defaultAccessAcl{
 			PublishClientSend:    false,
 			PublishClientSend:    false,