Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Store indicates which data store to use to hold the sessions.
// Available built in stores are "db", "redis", "mem"
Store string `config:"platform.server.session.store" default:"redis"`
// Enable the use of sessions
Enabled bool `config:"platform.server.session.enabled" default:"yes"`
// UseCookie will enable client sessions through cookies
UseCookie bool `config:"platform.server.session.useCookie" default:"yes"`
// CookieName for the session cookie
CookieName string `config:"platform.server.session.cookieName" default:"_session"`
// HeaderName of the header that will contain the session id
HeaderName string `config:"platform.server.session.headerName" default:"X-Session-Id"`
// TTL is the maximum inactivity of a session till it gets removed
TTL time.Duration `config:"platform.server.session.ttl" default:"1h"`
}
type Session ¶
type Session struct {
// Unique session id
ID Token `json:"sessionid" bson:"_id"`
// Map of values stored on the session
Data map[string]interface{} `json:"data" bson:"data"`
// LastActivity Last time the session was used
LastActivity time.Time `json:"lastactivity" bson:"lastActivity"`
// ip of user
IP string `json:"ip" bson:"ip"`
// CSRF token
CSRFToken string `json:"csrf" bson:"CSRF"`
// User agent of the session holder
UA string `json:"ua" bson:"UA"`
// Date when the session was created
Created time.Time `json:"created" bson:"created"`
// Persistent flag will keep the sessions alive for a longer period of time
Persistent bool `json:"persistent" bson:"persistent"`
// Name oif the user
Name *string `json:"name" bson:"name"`
// Account id if linked with account
AccountID *string `json:"accountid" bson:"accountId"`
// Account id if linked with account
ImpersonateAccountID *int `json:"impersonateAccountid" bson:"impersonateAccountid"`
// Unique device id
DeviceID *string `json:"deviceid" bson:"deviceId"`
// Session can be locked for various reasons
Locked bool `json:"locked" bson:"locked"`
// List of user permissions
Permissions *platform.Permissions `json:"permissions" bson:"permissions"`
}
User session
type Store ¶
type Store interface {
// Store factory
New() error
// Session store name
Type() string
// Stores a session in the store
Set(*Session) error
// Retrieves a session from the store
Get(Token) *Session
// Removes a session from the store
Del(Token) error
// List all available sessions.
// If argument is provided, it will return only sessions that match the account
List(*string) []*Session
// Removes all expired sessions
GC()
// Closes the store
Close()
}
Interface of a session store
Click to show internal directories.
Click to hide internal directories.