Browse Source

json tag fix,create client with password before hashing

Abhishek Kondur 2 years ago
parent
commit
fed66c4b8d
2 changed files with 26 additions and 5 deletions
  1. 2 2
      controllers/node.go
  2. 24 3
      mq/dynsec.go

+ 2 - 2
controllers/node.go

@@ -604,7 +604,7 @@ func createNode(w http.ResponseWriter, r *http.Request) {
 		Mine:   node.TrafficKeys.Mine,
 		Server: key,
 	}
-
+	nodePassword := node.Password
 	err = logic.CreateNode(&node)
 	if err != nil {
 		logger.Log(0, r.Header.Get("user"),
@@ -663,7 +663,7 @@ func createNode(w http.ResponseWriter, r *http.Request) {
 				{
 					Command:  mq.CreateClientCmd,
 					Username: node.ID,
-					Password: node.Password,
+					Password: nodePassword,
 					Textname: node.Name,
 					Roles:    make([]mq.MqDynSecRole, 0),
 					Groups:   make([]mq.MqDynSecGroup, 0),

+ 24 - 3
mq/dynsec.go

@@ -46,7 +46,7 @@ var (
 				TextName:   "netmaker metrics exporter",
 				Password:   "yl7HZglF4CvCxgjPLLIYc73LRtjEwp2/SAEQXeW5Ta1Dl4RoLN5/gjqiv8xmue+F9LfRk8KICkNbhSYuEfJ7ww==",
 				Salt:       "veLl9eN02i+hKkyT",
-				Iterations: 0,
+				Iterations: 101,
 				Roles:      []clientRole{},
 			},
 		},
@@ -79,6 +79,26 @@ var (
 						Topic:   "$SYS/#",
 						Allow:   true,
 					},
+					{
+						AclType: "publishClientReceive",
+						Topic:   "#",
+						Allow:   true,
+					},
+					{
+						AclType: "subscribePattern",
+						Topic:   "#",
+						Allow:   true,
+					},
+					{
+						AclType: "unsubscribePattern",
+						Topic:   "#",
+						Allow:   true,
+					},
+					{
+						AclType: "publishClientSend",
+						Topic:   "#",
+						Allow:   true,
+					},
 				},
 			},
 		},
@@ -165,9 +185,9 @@ type MqDynSecRole struct {
 }
 
 type Acl struct {
-	AclType  string `json:"acl_type"`
+	AclType  string `json:"acltype"`
 	Topic    string `json:"topic"`
-	Priority int    `json:"priority"`
+	Priority int    `json:"priority,omitempty"`
 	Allow    bool   `json:"allow"`
 }
 
@@ -203,6 +223,7 @@ func Configure() error {
 	if password == "" {
 		return errors.New("MQ admin password not provided")
 	}
+	fmt.Println("-----> PASSWORD: ", password)
 	for i, cI := range dynConfig.Clients {
 		if cI.Username == mqAdminUserName || cI.Username == mqNetmakerServerUserName {
 			salt := logic.RandomString(12)