Documentation ¶
Index ¶
- Variables
- func AddCustomResponseHeaders(cfg *setting.Cfg) web.Handler
- func AddDefaultResponseHeaders(cfg *setting.Cfg) web.Handler
- func Auth(options *AuthOptions) web.Handler
- func CanAdminPlugins(cfg *setting.Cfg, accessControl ac.AccessControl) func(c *contextmodel.ReqContext)
- func ContentSecurityPolicy(cfg *setting.Cfg, logger log.Logger) func(http.Handler) http.Handler
- func Gziper() func(http.Handler) http.Handler
- func HandleNoCacheHeaders(ctx *contextmodel.ReqContext)
- func NoAuth() web.Handler
- func OrgRedirect(cfg *setting.Cfg, userSvc user.Service) web.Handler
- func ProvideRouteOperationName(name string) web.Handler
- func Quota(quotaService quota.Service) func(string) web.Handler
- func Recovery(cfg *setting.Cfg, license licensing.Licensing) web.Middleware
- func RedirectFromLegacyPanelEditURL(cfg *setting.Cfg) func(c *contextmodel.ReqContext)
- func ReplacePolicyVariables(policyTemplate, appURL, nonce string) string
- func ReqNotSignedIn(c *contextmodel.ReqContext)
- func RequestMetrics(features featuremgmt.FeatureToggles, cfg *setting.Cfg, ...) web.Middleware
- func RequestTracing(tracer tracing.Tracer) web.Middleware
- func RoleAppPluginAuth(accessControl ac.AccessControl, ps pluginstore.Store, ...) func(c *contextmodel.ReqContext)
- func RoleAuth(roles ...org.RoleType) web.Handler
- func RouteOperationName(req *http.Request) (string, bool)
- func SnapshotPublicModeOrSignedIn(cfg *setting.Cfg) web.Handler
- func SubPathRedirect(cfg *setting.Cfg) web.Middleware
- func ValidateHostHeader(cfg *setting.Cfg) web.Handler
- type AuthOptions
Constants ¶
This section is empty.
Variables ¶
var ( ReqGrafanaAdmin = Auth(&AuthOptions{ ReqSignedIn: true, ReqGrafanaAdmin: true, }) ReqSignedIn = Auth(&AuthOptions{ReqSignedIn: true}) ReqSignedInNoAnonymous = Auth(&AuthOptions{ReqSignedIn: true, ReqNoAnonynmous: true}) ReqEditorRole = RoleAuth(org.RoleEditor, org.RoleAdmin) ReqOrgAdmin = RoleAuth(org.RoleAdmin) )
Functions ¶
func Auth ¶
func Auth(options *AuthOptions) web.Handler
func CanAdminPlugins ¶
func CanAdminPlugins(cfg *setting.Cfg, accessControl ac.AccessControl) func(c *contextmodel.ReqContext)
func ContentSecurityPolicy ¶
ContentSecurityPolicy sets the configured Content-Security-Policy and/or Content-Security-Policy-Report-Only header(s) in the response.
func HandleNoCacheHeaders ¶
func HandleNoCacheHeaders(ctx *contextmodel.ReqContext)
func NoAuth ¶
NoAuth creates a middleware that doesn't require any authentication. If forceLogin param is set it will redirect the user to the login page.
func OrgRedirect ¶
OrgRedirect changes org and redirects users if the querystring `orgId` doesn't match the active org.
func ProvideRouteOperationName ¶
ProvideRouteOperationName creates a named middleware responsible for populating the context with the route operation name that can be used later in the request pipeline. Implements routing.RegisterNamedMiddleware.
func Quota ¶
Quota returns a function that returns a function used to call quotaservice based on target name
func Recovery ¶
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one. While Martini is in development mode, Recovery will also output the panic as HTML.
func RedirectFromLegacyPanelEditURL ¶
func RedirectFromLegacyPanelEditURL(cfg *setting.Cfg) func(c *contextmodel.ReqContext)
In Grafana v7.0 we changed panel edit & view query parameters. This middleware tries to detect those old url parameters and direct to the new url query params
func ReplacePolicyVariables ¶
func ReqNotSignedIn ¶
func ReqNotSignedIn(c *contextmodel.ReqContext)
func RequestMetrics ¶
func RequestMetrics(features featuremgmt.FeatureToggles, cfg *setting.Cfg, promRegister prometheus.Registerer) web.Middleware
RequestMetrics is a middleware handler that instruments the request.
func RequestTracing ¶
func RequestTracing(tracer tracing.Tracer) web.Middleware
func RoleAppPluginAuth ¶
func RoleAppPluginAuth(accessControl ac.AccessControl, ps pluginstore.Store, features featuremgmt.FeatureToggles, logger log.Logger) func(c *contextmodel.ReqContext)
func RouteOperationName ¶
RouteOperationName receives the route operation name from context, if set.
func SnapshotPublicModeOrSignedIn ¶
SnapshotPublicModeOrSignedIn creates a middleware that allows access if snapshot public mode is enabled or if user is signed in.
func SubPathRedirect ¶
func SubPathRedirect(cfg *setting.Cfg) web.Middleware
SubPathRedirect Redirects URLs that are missing the configured subpath to an URL that contains the subpath.