middleware

package
v4.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: Apache-2.0 Imports: 30 Imported by: 707

Documentation

Index

Constants

View Source
const (
	SESS_KEY_USERID       = "uid"
	SESS_KEY_OAUTH_STATE  = "state"
	SESS_KEY_APIKEY       = "apikey_id" // used for render requests with api keys
	SESS_KEY_LASTLDAPSYNC = "last_ldap_sync"
)

Variables

This section is empty.

Functions

func AddDefaultResponseHeaders

func AddDefaultResponseHeaders() macaron.Handler

func AddRenderAuthKey

func AddRenderAuthKey(orgId int64) string

func Auth

func Auth(options *AuthOptions) macaron.Handler

func GetContextHandler

func GetContextHandler() macaron.Handler

func Gziper

func Gziper() macaron.Handler

func Logger

func Logger() macaron.Handler

func MeasureRequestTime

func MeasureRequestTime() macaron.Handler

func OrgRedirect

func OrgRedirect() macaron.Handler

func Quota

func Quota(target string) macaron.Handler

func QuotaReached

func QuotaReached(c *Context, target string) (bool, error)

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 RemoveRenderAuthKey

func RemoveRenderAuthKey(key string)

func RequestMetrics

func RequestMetrics(handler string) macaron.Handler

func RequestTracing

func RequestTracing(handler string) macaron.Handler

func RoleAuth

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

func Sessioner

func Sessioner(options *session.Options) macaron.Handler

func ValidateHostHeader

func ValidateHostHeader(domain string) macaron.Handler

Types

type AuthOptions

type AuthOptions struct {
	ReqGrafanaAdmin bool
	ReqSignedIn     bool
}

type Context

type Context struct {
	*macaron.Context
	*m.SignedInUser

	Session SessionStore

	IsSignedIn     bool
	IsRenderCall   bool
	AllowAnonymous bool
	Logger         log.Logger
}

func (*Context) Handle

func (ctx *Context) Handle(status int, title string, err error)

Handle handles and logs error by given status.

func (*Context) HasHelpFlag

func (ctx *Context) HasHelpFlag(flag m.HelpFlags1) bool

func (*Context) HasUserRole

func (ctx *Context) HasUserRole(role m.RoleType) bool

func (*Context) IsApiRequest

func (ctx *Context) IsApiRequest() bool

func (*Context) JsonApiErr

func (ctx *Context) JsonApiErr(status int, message string, err error)

func (*Context) JsonOK

func (ctx *Context) JsonOK(message string)

func (*Context) TimeRequest

func (ctx *Context) TimeRequest(timer prometheus.Summary)

type SessionStore

type SessionStore interface {
	// Set sets value to given key in session.
	Set(interface{}, interface{}) error
	// Get gets value by given key in session.
	Get(interface{}) interface{}
	// Delete deletes a key from session.
	Delete(interface{}) interface{}
	// ID returns current session ID.
	ID() string
	// Release releases session resource and save data to provider.
	Release() error
	// Destory deletes a session.
	Destory(*Context) error
	// init
	Start(*Context) error
	// RegenerateId regenerates the session id
	RegenerateId(*Context) error
}

func GetSession

func GetSession() SessionStore

type SessionWrapper

type SessionWrapper struct {
	// contains filtered or unexported fields
}

func (*SessionWrapper) Delete

func (s *SessionWrapper) Delete(k interface{}) interface{}

func (*SessionWrapper) Destory

func (s *SessionWrapper) Destory(c *Context) error

func (*SessionWrapper) Get

func (s *SessionWrapper) Get(k interface{}) interface{}

func (*SessionWrapper) ID

func (s *SessionWrapper) ID() string

func (*SessionWrapper) RegenerateId

func (s *SessionWrapper) RegenerateId(c *Context) error

func (*SessionWrapper) Release

func (s *SessionWrapper) Release() error

func (*SessionWrapper) Set

func (s *SessionWrapper) Set(k interface{}, v interface{}) error

func (*SessionWrapper) Start

func (s *SessionWrapper) Start(c *Context) error

Jump to

Keyboard shortcuts

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