RBAC: Display indicator if a permission is inherited (#54080)
* RBAC: Add IsInherited property * PermissionList: Display inherited indicator
This commit is contained in:
@@ -235,6 +235,7 @@ type ResourcePermission struct {
|
||||
Team string
|
||||
BuiltInRole string
|
||||
IsManaged bool
|
||||
IsInherited bool
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ type resourcePermissionDTO struct {
|
||||
ID int64 `json:"id"`
|
||||
RoleName string `json:"roleName"`
|
||||
IsManaged bool `json:"isManaged"`
|
||||
IsInherited bool `json:"isInherited"`
|
||||
UserID int64 `json:"userId,omitempty"`
|
||||
UserLogin string `json:"userLogin,omitempty"`
|
||||
UserAvatarUrl string `json:"userAvatarUrl,omitempty"`
|
||||
@@ -122,6 +123,7 @@ func (a *api) getPermissions(c *models.ReqContext) response.Response {
|
||||
Actions: p.Actions,
|
||||
Permission: permission,
|
||||
IsManaged: p.IsManaged,
|
||||
IsInherited: p.IsInherited,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func (p *flatResourcePermission) IsManaged(scope string) bool {
|
||||
}
|
||||
|
||||
func (p *flatResourcePermission) IsInherited(scope string) bool {
|
||||
return p.Scope != scope
|
||||
return !strings.HasPrefix(p.Scope, strings.Split(strings.ReplaceAll(scope, "*", ""), ":")[0])
|
||||
}
|
||||
|
||||
func (s *store) SetUserResourcePermission(
|
||||
@@ -482,6 +482,7 @@ func flatPermissionsToResourcePermission(scope string, permissions []flatResourc
|
||||
Created: first.Created,
|
||||
Updated: first.Updated,
|
||||
IsManaged: first.IsManaged(scope),
|
||||
IsInherited: first.IsInherited(scope),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user