Refactor RBAC rule cloning route for role

It moves role permission cloning under /system/roles from /system/permissions, since cloning action copies all rules, and it can not be limited per-component and also shifted all respective service methods to role service and removed Rbac rule cloning methods from access-control template.
This commit is contained in:
Vivek Patel
2022-07-10 15:47:26 +05:30
parent 2ffe8a2df0
commit d26ca37fe0
17 changed files with 216 additions and 225 deletions
@@ -25,7 +25,6 @@ type (
Evaluate(rbac.Session, string, rbac.Resource) rbac.Evaluated
Grant(context.Context, ...*rbac.Rule) error
FindRulesByRoleID(roleID uint64) (rr rbac.RuleSet)
CloneRulesByRoleID(ctx context.Context, fromRoleID uint64, toRoleID ...uint64) error
}
accessControl struct {
@@ -206,17 +205,6 @@ func (svc accessControl) FindRulesByRoleID(ctx context.Context, roleID uint64) (
return svc.rbac.FindRulesByRoleID(roleID), nil
}
// CloneRulesByRoleID clone all rules of a Role S to a specific Role T
//
// This function is auto-generated
func (svc accessControl) CloneRulesByRoleID(ctx context.Context, fromRoleID uint64, toRoleID ...uint64) error {
if !svc.CanGrant(ctx) {
return AccessControlErrNotAllowedToSetPermissions()
}
return svc.rbac.CloneRulesByRoleID(ctx, fromRoleID, toRoleID...)
}
{{- range .operations }}
// {{ .checkFuncName }} checks if current user can {{ lower .description }}
//