RBAC: Fix delete team permissions on team delete (#83442)

* RBAC: Remove team permissions on delete

* Remove unecessary deletes from store function

* Nit on mock

* Add test to the database

* Nit on comment

* Add another test to check that other permissions remain
This commit is contained in:
Gabriel MABILLE
2024-02-27 12:21:26 +01:00
committed by GitHub
parent ffae7d111c
commit 8d9921a5ba
9 changed files with 178 additions and 5 deletions
@@ -35,6 +35,9 @@ type Service interface {
// DeleteUserPermissions removes all permissions user has in org and all permission to that user
// If orgID is set to 0 remove permissions from all orgs
DeleteUserPermissions(ctx context.Context, orgID, userID int64) error
// DeleteTeamPermissions removes all role assignments and permissions granted to a team
// and removes permissions scoped to the team.
DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error
// DeclareFixedRoles allows the caller to declare, to the service, fixed roles and their
// assignments to organization roles ("Viewer", "Editor", "Admin") or "Grafana Admin"
DeclareFixedRoles(registrations ...RoleRegistration) error
@@ -52,6 +55,7 @@ type Store interface {
SearchUsersPermissions(ctx context.Context, orgID int64, options SearchOptions) (map[int64][]Permission, error)
GetUsersBasicRoles(ctx context.Context, userFilter []int64, orgID int64) (map[int64][]string, error)
DeleteUserPermissions(ctx context.Context, orgID, userID int64) error
DeleteTeamPermissions(ctx context.Context, orgID, teamID int64) error
SaveExternalServiceRole(ctx context.Context, cmd SaveExternalServiceRoleCommand) error
DeleteExternalServiceRole(ctx context.Context, externalServiceID string) error
}