Explorar o código

fix global network role access

abhishek9686 hai 10 meses
pai
achega
2852314762
Modificáronse 2 ficheiros con 10 adicións e 1 borrados
  1. 9 0
      pro/logic/security.go
  2. 1 1
      pro/logic/user_mgmt.go

+ 9 - 0
pro/logic/security.go

@@ -82,8 +82,17 @@ func NetworkPermissionsCheck(username string, r *http.Request) error {
 		}
 	}
 	for groupID := range user.UserGroups {
+
 		userG, err := GetUserGroup(groupID)
 		if err == nil {
+			if netRoles, ok := userG.NetworkRoles[models.AllNetworks]; ok {
+				for netRoleID := range netRoles {
+					err = checkNetworkAccessPermissions(netRoleID, username, r.Method, targetRsrc, targetRsrcID, netID)
+					if err == nil {
+						return nil
+					}
+				}
+			}
 			netRoles := userG.NetworkRoles[models.NetworkID(netID)]
 			for netRoleID := range netRoles {
 				err = checkNetworkAccessPermissions(netRoleID, username, r.Method, targetRsrc, targetRsrcID, netID)

+ 1 - 1
pro/logic/user_mgmt.go

@@ -87,7 +87,7 @@ func UserGroupsInit() {
 		Name:     "Network Admin Group",
 		MetaData: "Users in this group can manage all your networks configuration.",
 		NetworkRoles: map[models.NetworkID]map[models.UserRoleID]struct{}{
-			models.NetworkID("*"): {
+			models.AllNetworks: {
 				models.UserRoleID(fmt.Sprintf("global-%s", models.NetworkAdmin)): {},
 			},
 		},