middleware

package
v0.0.0-testrgm4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 56 Imported by: 680

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 AddCustomResponseHeaders

func AddCustomResponseHeaders(cfg *setting.Cfg) web.Handler

func AddDefaultResponseHeaders

func AddDefaultResponseHeaders(cfg *setting.Cfg) web.Handler

func AdminOrEditorAndFeatureEnabled

func AdminOrEditorAndFeatureEnabled(enabled bool) web.Handler

AdminOrEditorAndFeatureEnabled creates a middleware that allows access if the signed in user is either an Org Admin or if they are an Org Editor and the feature flag is enabled. Intended for when feature flags open up access to APIs that are otherwise only available to admins.

func Auth

func Auth(options *AuthOptions) web.Handler

func CanAdminPlugins

func CanAdminPlugins(cfg *setting.Cfg) func(c *contextmodel.ReqContext)

func ContentSecurityPolicy

func ContentSecurityPolicy(cfg *setting.Cfg, logger log.Logger) func(http.Handler) http.Handler

ContentSecurityPolicy sets the configured Content-Security-Policy and/or Content-Security-Policy-Report-Only header(s) in the response.

func EnsureEditorOrViewerCanEdit

func EnsureEditorOrViewerCanEdit(cfg *setting.Cfg) func(c *contextmodel.ReqContext)

func Gziper

func Gziper() func(http.Handler) http.Handler

func HandleNoCacheHeader

func HandleNoCacheHeader(ctx *contextmodel.ReqContext)

func NoAuth

func NoAuth() web.Handler

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 OrgAdminDashOrFolderAdminOrTeamAdmin

func OrgAdminDashOrFolderAdminOrTeamAdmin(ss db.DB, ds dashboards.DashboardService, ts team.Service) func(c *contextmodel.ReqContext)

func OrgRedirect

func OrgRedirect(cfg *setting.Cfg, userSvc user.Service) web.Handler

OrgRedirect changes org and redirects users if the querystring `orgId` doesn't match the active org.

func ProvideRouteOperationName

func ProvideRouteOperationName(name string) web.Handler

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

func Quota(quotaService quota.Service) func(string) web.Handler

Quota returns a function that returns a function used to call quotaservice based on target name

func Recovery

func Recovery(cfg *setting.Cfg) web.Middleware

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 ReqNotSignedIn

func ReqNotSignedIn(c *contextmodel.ReqContext)

func RequestMetrics

func RequestMetrics(features featuremgmt.FeatureToggles) web.Middleware

RequestMetrics is a middleware handler that instruments the request.

func RequestTracing

func RequestTracing(tracer tracing.Tracer) web.Middleware

func RoleAuth

func RoleAuth(roles ...org.RoleType) web.Handler

func RouteOperationName

func RouteOperationName(req *http.Request) (string, bool)

RouteOperationName receives the route operation name from context, if set.

func SnapshotPublicModeOrSignedIn

func SnapshotPublicModeOrSignedIn(cfg *setting.Cfg) web.Handler

SnapshotPublicModeOrSignedIn creates a middleware that allows access if snapshot public mode is enabled or if user is signed in.

func ValidateHostHeader

func ValidateHostHeader(cfg *setting.Cfg) web.Handler

Types

type AuthOptions

type AuthOptions struct {
	ReqGrafanaAdmin bool
	ReqSignedIn     bool
	ReqNoAnonynmous bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL