Documentation ¶
Index ¶
- Variables
- func AddCSPHeader(cfg *setting.Cfg, logger log.Logger) macaron.Handler
- func AddDefaultResponseHeaders(cfg *setting.Cfg) macaron.Handler
- func AdminOrEditorAndFeatureEnabled(enabled bool) macaron.Handler
- func Auth(options *AuthOptions) macaron.Handler
- func CSRF(loginCookieName string) http.Handler
- func EnsureEditorOrViewerCanEdit(c *models.ReqContext)
- func Gziper() macaron.Handler
- func HandleNoCacheHeader(ctx *models.ReqContext)
- func Logger(cfg *setting.Cfg) macaron.Handler
- func NoAuth() macaron.Handler
- func OrgRedirect(cfg *setting.Cfg) macaron.Handler
- func Quota(quotaService *quota.QuotaService) func(string) macaron.Handler
- func RateLimit(rps, burst int, getTime getTimeFn) macaron.Handler
- func Recovery(cfg *setting.Cfg) macaron.Handler
- func RedirectFromLegacyDashboardSoloURL(cfg *setting.Cfg) func(c *models.ReqContext)
- func RedirectFromLegacyDashboardURL() func(c *models.ReqContext)
- func RedirectFromLegacyPanelEditURL(cfg *setting.Cfg) func(c *models.ReqContext)
- func RequestMetrics(cfg *setting.Cfg) func(handler string) macaron.Handler
- func RequestTracing(handler string) macaron.Handler
- func RoleAuth(roles ...models.RoleType) macaron.Handler
- func SnapshotPublicModeOrSignedIn(cfg *setting.Cfg) macaron.Handler
- func ValidateHostHeader(cfg *setting.Cfg) macaron.Handler
- type AuthOptions
Constants ¶
This section is empty.
Variables ¶
var ( ReqGrafargAdmin = Auth(&AuthOptions{ ReqSignedIn: true, ReqGrafargAdmin: true, }) ReqSignedIn = Auth(&AuthOptions{ReqSignedIn: true}) ReqSignedInNoAnonymous = Auth(&AuthOptions{ReqSignedIn: true, ReqNoAnonynmous: true}) ReqEditorRole = RoleAuth(models.ROLE_EDITOR, models.ROLE_ADMIN) ReqOrgAdmin = RoleAuth(models.ROLE_ADMIN) )
Functions ¶
func AddCSPHeader ¶
AddCSPHeader adds the Content Security Policy header.
func AdminOrEditorAndFeatureEnabled ¶
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) macaron.Handler
func EnsureEditorOrViewerCanEdit ¶
func EnsureEditorOrViewerCanEdit(c *models.ReqContext)
func HandleNoCacheHeader ¶
func HandleNoCacheHeader(ctx *models.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 Quota ¶
func Quota(quotaService *quota.QuotaService) func(string) macaron.Handler
Quota returns a function that returns a function used to call quotaservice based on target name
func RateLimit ¶
func RateLimit(rps, burst int, getTime getTimeFn) macaron.Handler
RateLimit is a very basic rate limiter. Will allow average of "rps" requests per second over an extended period of time, with max "burst" requests at the same time. getTime should return the current time. For non-testing purposes use time.Now
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 RedirectFromLegacyDashboardSoloURL ¶
func RedirectFromLegacyDashboardSoloURL(cfg *setting.Cfg) func(c *models.ReqContext)
func RedirectFromLegacyDashboardURL ¶
func RedirectFromLegacyDashboardURL() func(c *models.ReqContext)
func RedirectFromLegacyPanelEditURL ¶
func RedirectFromLegacyPanelEditURL(cfg *setting.Cfg) func(c *models.ReqContext)
In Grafarg 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 ¶
RequestMetrics is a middleware handler that instruments the request
func RequestTracing ¶
func RequestTracing(handler string) macaron.Handler
func SnapshotPublicModeOrSignedIn ¶
SnapshotPublicModeOrSignedIn creates a middleware that allows access if snapshot public mode is enabled or if user is signed in.