mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AccessControl: Only return action and scope for user permissions and make them unique (#48939)
* Only return action and scope for user permissions and make them unique
This commit is contained in:
parent
6cbaa18cf6
commit
1c679e814b
@ -21,7 +21,7 @@ type AccessControl interface {
|
||||
// Evaluate evaluates access to the given resources.
|
||||
Evaluate(ctx context.Context, user *models.SignedInUser, evaluator Evaluator) (bool, error)
|
||||
|
||||
// GetUserPermissions returns user permissions.
|
||||
// GetUserPermissions returns user permissions with only action and scope fields set.
|
||||
GetUserPermissions(ctx context.Context, user *models.SignedInUser, options Options) ([]*Permission, error)
|
||||
|
||||
// GetUserRoles returns user roles.
|
||||
@ -40,6 +40,7 @@ type AccessControl interface {
|
||||
}
|
||||
|
||||
type PermissionsProvider interface {
|
||||
// GetUserPermissions returns user permissions with only action and scope fields set.
|
||||
GetUserPermissions(ctx context.Context, query GetUserPermissionsQuery) ([]*Permission, error)
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,9 @@ func (s *AccessControlStore) GetUserPermissions(ctx context.Context, query acces
|
||||
filter, params := userRolesFilter(query.OrgID, query.UserID, query.Roles)
|
||||
|
||||
// TODO: optimize this
|
||||
q := `SELECT
|
||||
permission.id,
|
||||
permission.role_id,
|
||||
q := `SELECT DISTINCT
|
||||
permission.action,
|
||||
permission.scope,
|
||||
permission.updated,
|
||||
permission.created
|
||||
permission.scope
|
||||
FROM permission
|
||||
INNER JOIN role ON role.id = permission.role_id
|
||||
` + filter
|
||||
|
Loading…
Reference in New Issue
Block a user