RBAC: Change annotation filter to use dashboard based annotation scopes (#78635)

change annotation filter to use dash based annotation scopes
This commit is contained in:
Ieva
2023-11-29 05:34:44 -05:00
committed by GitHub
parent ff7dd17c56
commit 791881f910
7 changed files with 130 additions and 66 deletions
@@ -369,11 +369,11 @@ func (r *xormRepositoryImpl) Get(ctx context.Context, query *annotations.ItemQue
func (r *xormRepositoryImpl) getAccessControlFilter(user identity.Requester, accessResources *accesscontrol.AccessResources) (string, error) {
var filters []string
if _, has := accessResources.ScopeTypes[annotations.Organization.String()]; has {
if accessResources.CanAccessOrgAnnotations {
filters = append(filters, "a.dashboard_id = 0")
}
if _, has := accessResources.ScopeTypes[annotations.Dashboard.String()]; has {
if accessResources.CanAccessDashAnnotations {
var dashboardIDs []int64
for _, id := range accessResources.Dashboards {
dashboardIDs = append(dashboardIDs, id)