diff --git a/pkg/api/index.go b/pkg/api/index.go index 1e444307873..89184f60c3e 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -577,7 +577,7 @@ func (hs *HTTPServer) buildCreateNavLinks(c *models.ReqContext) []*dtos.NavLink hasAccess := ac.HasAccess(hs.AccessControl, c) var children []*dtos.NavLink - if hasAccess(ac.ReqSignedIn, ac.EvalPermission(ac.ActionDashboardsCreate)) { + if hasAccess(ac.NoReq, ac.EvalPermission(ac.ActionDashboardsCreate)) { children = append(children, &dtos.NavLink{Text: "Dashboard", Icon: "apps", Url: hs.Cfg.AppSubURL + "/dashboard/new", Id: "create-dashboard"}) } @@ -588,7 +588,7 @@ func (hs *HTTPServer) buildCreateNavLinks(c *models.ReqContext) []*dtos.NavLink }) } - if hasAccess(ac.ReqSignedIn, ac.EvalPermission(ac.ActionDashboardsCreate)) { + if hasAccess(ac.NoReq, ac.EvalPermission(ac.ActionDashboardsCreate)) { children = append(children, &dtos.NavLink{ Text: "Import", SubTitle: "Import dashboard from file or Grafana.com", Id: "import", Icon: "import", Url: hs.Cfg.AppSubURL + "/dashboard/import", @@ -598,7 +598,7 @@ func (hs *HTTPServer) buildCreateNavLinks(c *models.ReqContext) []*dtos.NavLink _, uaIsDisabledForOrg := hs.Cfg.UnifiedAlerting.DisabledOrgs[c.OrgId] uaVisibleForOrg := hs.Cfg.UnifiedAlerting.IsEnabled() && !uaIsDisabledForOrg - if uaVisibleForOrg && hasAccess(ac.ReqSignedIn, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) { + if uaVisibleForOrg && hasAccess(ac.NoReq, ac.EvalAny(ac.EvalPermission(ac.ActionAlertingRuleCreate), ac.EvalPermission(ac.ActionAlertingRuleExternalWrite))) { children = append(children, &dtos.NavLink{ Text: "Alert rule", SubTitle: "Create an alert rule", Id: "alert", Icon: "bell", Url: hs.Cfg.AppSubURL + "/alerting/new", diff --git a/pkg/services/accesscontrol/accesscontrol.go b/pkg/services/accesscontrol/accesscontrol.go index a1c2c02b85a..79b6c2e1818 100644 --- a/pkg/services/accesscontrol/accesscontrol.go +++ b/pkg/services/accesscontrol/accesscontrol.go @@ -108,6 +108,10 @@ func HasAccess(ac AccessControl, c *models.ReqContext) func(fallback func(*model } } +var NoReq = func(c *models.ReqContext) bool { + return true +} + var ReqSignedIn = func(c *models.ReqContext) bool { return c.IsSignedIn }