middleware

package
v0.0.0-...-34a2968 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderNameNoBackendCache = "X-Grafana-NoCache"

Variables

View Source
var (
	ReqGrafanaAdmin = Auth(&AuthOptions{
		ReqSignedIn:     true,
		ReqGrafanaAdmin: true,
	})
	ReqSignedIn   = Auth(&AuthOptions{ReqSignedIn: true})
	ReqEditorRole = RoleAuth(models.ROLE_EDITOR, models.ROLE_ADMIN)
	ReqOrgAdmin   = RoleAuth(models.ROLE_ADMIN)
)

Functions

func AddDefaultResponseHeaders

func AddDefaultResponseHeaders() macaron.Handler

func AddNoCacheHeaders

func AddNoCacheHeaders(w macaron.ResponseWriter)

func AddSecurityHeaders

func AddSecurityHeaders(w macaron.ResponseWriter)

AddSecurityHeaders adds various HTTP(S) response headers that enable various security protections behaviors in the client's browser.

func AddXFrameOptionsDenyHeader

func AddXFrameOptionsDenyHeader(w macaron.ResponseWriter)

func AdminOrFeatureEnabled

func AdminOrFeatureEnabled(enabled bool) macaron.Handler

AdminOrFeatureEnabled creates a middleware that allows access if the signed in user is either an Org Admin or if 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) macaron.Handler

func DeleteCookie

func DeleteCookie(w http.ResponseWriter, name string, getCookieOptionsFunc GetCookieOptionsFunc)

func EnsureEditorOrViewerCanEdit

func EnsureEditorOrViewerCanEdit(c *models.ReqContext)

func GetContextHandler

func GetContextHandler(
	ats models.UserTokenService,
	remoteCache *remotecache.RemoteCache,
	renderService rendering.Service,
) macaron.Handler

func Gziper

func Gziper() macaron.Handler

func HandleNoCacheHeader

func HandleNoCacheHeader() macaron.Handler

func Logger

func Logger() macaron.Handler

func MeasureRequestTime

func MeasureRequestTime() macaron.Handler

func OrgRedirect

func OrgRedirect() macaron.Handler

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

func Quota

func Quota(quotaService *quota.QuotaService) func(target string) macaron.Handler

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

func Recovery

func Recovery() macaron.Handler

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 RedirectFromLegacyDashboardSoloURL

func RedirectFromLegacyDashboardSoloURL() macaron.Handler

func RedirectFromLegacyDashboardURL

func RedirectFromLegacyDashboardURL() macaron.Handler

func RedirectFromLegacyPanelEditURL

func RedirectFromLegacyPanelEditURL() macaron.Handler

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 RequestMetrics

func RequestMetrics(handler string) macaron.Handler

RequestMetrics is a middleware handler that instruments the request

func RequestTracing

func RequestTracing(handler string) macaron.Handler

func RoleAuth

func RoleAuth(roles ...models.RoleType) macaron.Handler

func SnapshotPublicModeOrSignedIn

func SnapshotPublicModeOrSignedIn() macaron.Handler

func ValidateHostHeader

func ValidateHostHeader(domain string) macaron.Handler

func WriteCookie

func WriteCookie(w http.ResponseWriter, name string, value string, maxAge int, getCookieOptionsFunc GetCookieOptionsFunc)

func WriteSessionCookie

func WriteSessionCookie(ctx *models.ReqContext, value string, maxLifetime time.Duration)

Types

type AuthOptions

type AuthOptions struct {
	ReqGrafanaAdmin bool
	ReqSignedIn     bool
}

type CookieOptions

type CookieOptions struct {
	Path             string
	Secure           bool
	SameSiteDisabled bool
	SameSiteMode     http.SameSite
}

type GetCookieOptionsFunc

type GetCookieOptionsFunc func() CookieOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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