|
@@ -626,10 +626,8 @@ func (c *CLI) registerDefaultCommands() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
case "update":
|
|
case "update":
|
|
|
- // Simplistic update: user role update <name> parents=p1,p2
|
|
|
|
|
- // Complex permissions editing is hard in CLI without JSON
|
|
|
|
|
if len(roleArgs) < 1 {
|
|
if len(roleArgs) < 1 {
|
|
|
- printBoxed("Usage: user role update <name> [parents=p1,p2]")
|
|
|
|
|
|
|
+ printBoxed("Usage: user role update <name> [parents=p1,p2] [perms=action:pattern,...]")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
name := roleArgs[0]
|
|
name := roleArgs[0]
|
|
@@ -653,6 +651,24 @@ func (c *CLI) registerDefaultCommands() {
|
|
|
targetRole.ParentRoles = strings.Split(pStr, ",")
|
|
targetRole.ParentRoles = strings.Split(pStr, ",")
|
|
|
updated = true
|
|
updated = true
|
|
|
}
|
|
}
|
|
|
|
|
+ if strings.HasPrefix(arg, "perms=") {
|
|
|
|
|
+ permStr := strings.TrimPrefix(arg, "perms=")
|
|
|
|
|
+ rules := strings.Split(permStr, ",")
|
|
|
|
|
+ var newPerms []Permission
|
|
|
|
|
+ for _, r := range rules {
|
|
|
|
|
+ parts := strings.SplitN(r, ":", 2)
|
|
|
|
|
+ if len(parts) == 2 {
|
|
|
|
|
+ action := parts[0]
|
|
|
|
|
+ pattern := parts[1]
|
|
|
|
|
+ newPerms = append(newPerms, Permission{
|
|
|
|
|
+ KeyPattern: pattern,
|
|
|
|
|
+ Actions: []string{action},
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ targetRole.Permissions = newPerms
|
|
|
|
|
+ updated = true
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if updated {
|
|
if updated {
|