1
0
mirror of https://github.com/volatiletech/authboss.git synced 2024-12-10 10:40:07 +02:00
authboss/context.go

30 lines
728 B
Go
Raw Normal View History

package authboss
// Context provides context for module operations and callbacks. One obvious
// need for context is a request's session store. It is not safe for use by
// multiple goroutines.
type Context struct {
SessionStorer ClientStorer
CookieStorer ClientStorer
User Attributes
keyValues map[string]interface{}
}
func NewContext() *Context {
return &Context{
keyValues: make(map[string]interface{}),
}
}
// Put an arbitrary key-value into the context.
func (c *Context) Put(key string, thing interface{}) {
c.keyValues[key] = thing
}
// Get an arbitrary key-value from the context.
func (c *Context) Get(key string) (thing interface{}, ok bool) {
thing, ok = c.keyValues[key]
return thing, ok
}