mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RBAC: Display indicator if a permission is inherited (#54080)
* RBAC: Add IsInherited property * PermissionList: Display inherited indicator
This commit is contained in:
parent
eb4266a85e
commit
cc78486535
@ -235,6 +235,7 @@ type ResourcePermission struct {
|
|||||||
Team string
|
Team string
|
||||||
BuiltInRole string
|
BuiltInRole string
|
||||||
IsManaged bool
|
IsManaged bool
|
||||||
|
IsInherited bool
|
||||||
Created time.Time
|
Created time.Time
|
||||||
Updated time.Time
|
Updated time.Time
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ type resourcePermissionDTO struct {
|
|||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
RoleName string `json:"roleName"`
|
RoleName string `json:"roleName"`
|
||||||
IsManaged bool `json:"isManaged"`
|
IsManaged bool `json:"isManaged"`
|
||||||
|
IsInherited bool `json:"isInherited"`
|
||||||
UserID int64 `json:"userId,omitempty"`
|
UserID int64 `json:"userId,omitempty"`
|
||||||
UserLogin string `json:"userLogin,omitempty"`
|
UserLogin string `json:"userLogin,omitempty"`
|
||||||
UserAvatarUrl string `json:"userAvatarUrl,omitempty"`
|
UserAvatarUrl string `json:"userAvatarUrl,omitempty"`
|
||||||
@ -122,6 +123,7 @@ func (a *api) getPermissions(c *models.ReqContext) response.Response {
|
|||||||
Actions: p.Actions,
|
Actions: p.Actions,
|
||||||
Permission: permission,
|
Permission: permission,
|
||||||
IsManaged: p.IsManaged,
|
IsManaged: p.IsManaged,
|
||||||
|
IsInherited: p.IsInherited,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func (p *flatResourcePermission) IsManaged(scope string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *flatResourcePermission) IsInherited(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(
|
func (s *store) SetUserResourcePermission(
|
||||||
@ -482,6 +482,7 @@ func flatPermissionsToResourcePermission(scope string, permissions []flatResourc
|
|||||||
Created: first.Created,
|
Created: first.Created,
|
||||||
Updated: first.Updated,
|
Updated: first.Updated,
|
||||||
IsManaged: first.IsManaged(scope),
|
IsManaged: first.IsManaged(scope),
|
||||||
|
IsInherited: first.IsInherited(scope),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ export const PermissionList = ({ title, items, permissionLevels, canSet, onRemov
|
|||||||
<tr>
|
<tr>
|
||||||
<th style={{ width: '1%' }} />
|
<th style={{ width: '1%' }} />
|
||||||
<th>{title}</th>
|
<th>{title}</th>
|
||||||
|
<th style={{ width: '1%' }} />
|
||||||
<th>Permission</th>
|
<th>Permission</th>
|
||||||
<th style={{ width: '1%' }} />
|
<th style={{ width: '1%' }} />
|
||||||
<th style={{ width: '1%' }} />
|
<th style={{ width: '1%' }} />
|
||||||
|
@ -16,6 +16,7 @@ export const PermissionListItem = ({ item, permissionLevels, canSet, onRemove, o
|
|||||||
<tr>
|
<tr>
|
||||||
<td style={{ width: '1%' }}>{getAvatar(item)}</td>
|
<td style={{ width: '1%' }}>{getAvatar(item)}</td>
|
||||||
<td style={{ width: '90%' }}>{getDescription(item)}</td>
|
<td style={{ width: '90%' }}>{getDescription(item)}</td>
|
||||||
|
<td>{item.isInherited && <em className="muted no-wrap">Inherited from folder</em>}</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="gf-form">
|
<div className="gf-form">
|
||||||
<Select
|
<Select
|
||||||
@ -43,7 +44,7 @@ export const PermissionListItem = ({ item, permissionLevels, canSet, onRemove, o
|
|||||||
aria-label={`Remove permission for ${getName(item)}`}
|
aria-label={`Remove permission for ${getName(item)}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Tooltip content="Provisioned permission">
|
<Tooltip content={item.isInherited ? 'Inherited Permission' : 'Provisioned Permission'}>
|
||||||
<Button size="sm" icon="lock" />
|
<Button size="sm" icon="lock" />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
@ -2,6 +2,7 @@ export type ResourcePermission = {
|
|||||||
id: number;
|
id: number;
|
||||||
resourceId: string;
|
resourceId: string;
|
||||||
isManaged: boolean;
|
isManaged: boolean;
|
||||||
|
isInherited: boolean;
|
||||||
userId?: number;
|
userId?: number;
|
||||||
userLogin?: string;
|
userLogin?: string;
|
||||||
userAvatarUrl?: string;
|
userAvatarUrl?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user