From f36ad469d03ff6c930e049b3d13165048b0705a9 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 14 Mar 2024 16:17:24 +0100 Subject: [PATCH] Access Control: Get global role from request params (#84469) --- pkg/services/accesscontrol/middleware.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/services/accesscontrol/middleware.go b/pkg/services/accesscontrol/middleware.go index 6cb0f6f485b..ed79b13c604 100644 --- a/pkg/services/accesscontrol/middleware.go +++ b/pkg/services/accesscontrol/middleware.go @@ -352,6 +352,15 @@ func UseGlobalOrgFromRequestData(c *contextmodel.ReqContext) (int64, error) { return c.SignedInUser.GetOrgID(), nil } +// UseGlobalOrgFromRequestParams returns global org if `global` flag is set or the org where user is logged in. +func UseGlobalOrgFromRequestParams(c *contextmodel.ReqContext) (int64, error) { + if c.QueryBool("global") { + return GlobalOrgID, nil + } + + return c.SignedInUser.GetOrgID(), nil +} + func getOrgQueryFromRequest(c *contextmodel.ReqContext) (*QueryWithOrg, error) { query := &QueryWithOrg{}