Documentation ¶
Index ¶
- Constants
- func AddDefaultResponseHeaders() macaron.Handler
- func AddRenderAuthKey(orgId int64, userId int64, orgRole m.RoleType) string
- func Auth(options *AuthOptions) macaron.Handler
- func GetContextHandler() macaron.Handler
- func Gziper() macaron.Handler
- func Logger() macaron.Handler
- func MeasureRequestTime() macaron.Handler
- func OrgRedirect() macaron.Handler
- func Quota(target string) macaron.Handler
- func QuotaReached(c *Context, target string) (bool, error)
- func Recovery() macaron.Handler
- func RedirectFromLegacyDashboardSoloUrl() macaron.Handler
- func RedirectFromLegacyDashboardUrl() macaron.Handler
- func RemoveRenderAuthKey(key string)
- func RequestMetrics(handler string) macaron.Handler
- func RequestTracing(handler string) macaron.Handler
- func RoleAuth(roles ...m.RoleType) macaron.Handler
- func Sessioner(options *session.Options, connMaxLifetime int64) macaron.Handler
- func ValidateHostHeader(domain string) macaron.Handler
- type AuthOptions
- type Context
- func (ctx *Context) Handle(status int, title string, err error)
- func (ctx *Context) HasHelpFlag(flag m.HelpFlags1) bool
- func (ctx *Context) HasUserRole(role m.RoleType) bool
- func (ctx *Context) IsApiRequest() bool
- func (ctx *Context) JsonApiErr(status int, message string, err error)
- func (ctx *Context) JsonOK(message string)
- func (ctx *Context) TimeRequest(timer prometheus.Summary)
- type MysqlProvider
- func (p *MysqlProvider) Count() (total int)
- func (p *MysqlProvider) Destory(sid string) error
- func (p *MysqlProvider) Exist(sid string) bool
- func (p *MysqlProvider) GC()
- func (p *MysqlProvider) Init(expire int64, connStr string) (err error)
- func (p *MysqlProvider) Read(sid string) (session.RawStore, error)
- func (p *MysqlProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
- type MysqlStore
- type SessionStore
- type SessionWrapper
- func (s *SessionWrapper) Delete(k interface{}) interface{}
- func (s *SessionWrapper) Destory(c *Context) error
- func (s *SessionWrapper) Get(k interface{}) interface{}
- func (s *SessionWrapper) ID() string
- func (s *SessionWrapper) RegenerateId(c *Context) error
- func (s *SessionWrapper) Release() error
- func (s *SessionWrapper) Set(k interface{}, v interface{}) error
- func (s *SessionWrapper) Start(c *Context) error
Constants ¶
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 Auth ¶
func Auth(options *AuthOptions) macaron.Handler
func GetContextHandler ¶
func GetContextHandler() macaron.Handler
func MeasureRequestTime ¶
func MeasureRequestTime() macaron.Handler
func OrgRedirect ¶
func OrgRedirect() macaron.Handler
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 RemoveRenderAuthKey ¶
func RemoveRenderAuthKey(key string)
func RequestMetrics ¶
func RequestMetrics(handler string) macaron.Handler
func RequestTracing ¶
func RequestTracing(handler string) macaron.Handler
func ValidateHostHeader ¶
func ValidateHostHeader(domain string) macaron.Handler
Types ¶
type AuthOptions ¶
type Context ¶
type Context struct { *macaron.Context *m.SignedInUser Session SessionStore IsSignedIn bool IsRenderCall bool AllowAnonymous bool Logger log.Logger }
func (*Context) HasHelpFlag ¶
func (ctx *Context) HasHelpFlag(flag m.HelpFlags1) bool
func (*Context) IsApiRequest ¶
func (*Context) TimeRequest ¶
func (ctx *Context) TimeRequest(timer prometheus.Summary)
type MysqlProvider ¶
type MysqlProvider struct {
// contains filtered or unexported fields
}
MysqlProvider represents a mysql session provider implementation.
func (*MysqlProvider) Count ¶
func (p *MysqlProvider) Count() (total int)
Count counts and returns number of sessions.
func (*MysqlProvider) Destory ¶
func (p *MysqlProvider) Destory(sid string) error
Destory deletes a session by session ID.
func (*MysqlProvider) Exist ¶
func (p *MysqlProvider) Exist(sid string) bool
Exist returns true if session with given ID exists.
func (*MysqlProvider) Init ¶
func (p *MysqlProvider) Init(expire int64, connStr string) (err error)
Init initializes mysql session provider. connStr: username:password@protocol(address)/dbname?param=value
func (*MysqlProvider) Read ¶
func (p *MysqlProvider) Read(sid string) (session.RawStore, error)
Read returns raw session store by session ID.
func (*MysqlProvider) Regenerate ¶
func (p *MysqlProvider) Regenerate(oldsid, sid string) (_ session.RawStore, err error)
Regenerate regenerates a session store from old session ID to new one.
type MysqlStore ¶
type MysqlStore struct {
// contains filtered or unexported fields
}
MysqlStore represents a mysql session store implementation.
func NewMysqlStore ¶
func NewMysqlStore(c *sql.DB, sid string, kv map[interface{}]interface{}) *MysqlStore
NewMysqlStore creates and returns a mysql session store.
func (*MysqlStore) Delete ¶
func (s *MysqlStore) Delete(key interface{}) error
Delete delete a key from session.
func (*MysqlStore) Get ¶
func (s *MysqlStore) Get(key interface{}) interface{}
Get gets value by given key in session.
func (*MysqlStore) Release ¶
func (s *MysqlStore) Release() error
Release releases resource and save data to provider.
func (*MysqlStore) Set ¶
func (s *MysqlStore) Set(key, val interface{}) error
Set sets value to given key in session.
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