Documentation
¶
Index ¶
- func SetupTable(applicationName string, orgName string, production bool, dbHost string, ...) error
- type Session
- func (sessionObject *Session) CheckStatus(sessionToken string) (SessionData, error)
- func (sessionObject *Session) DeleteSession(sessionToken string) error
- func (sessionObject *Session) FetchAllSessions() ([]SessionData, error)
- func (sessionObject *Session) FetchSessionData(session SessionData) (SessionData, error)
- func (sessionObject *Session) NewSession(key string, ipAddress string) (SessionData, error)
- type SessionData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupTable ¶ added in v1.0.1
func SetupTable(applicationName string, orgName string, production bool, dbHost string, dbPort uint16, databaseName string, dbUser string, dbPassword string, defaultSchema string) error
SetupTable accepts all the parameters and creates/updates the Sessions table. Don't call it along with Init(). Init() and SetupTable() should be called separately.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages all the sessions
func Init ¶ added in v1.0.1
func Init(sessionExpiresInSecs int64, sessionLocalTimezoneName string, applicationName string, orgName string, production bool, dbHost string, dbPort uint16, databaseName string, dbUser string, dbPassword string) (*Session, error)
Init accepts number of seconds after which the session expires (if set to 0, default value of 86400 is used), the timezone (if set to "", default timezone - UTC is used), and sets up the required variables. It also starts the expiry timers of existing sessions.
func (*Session) CheckStatus ¶ added in v1.0.1
func (sessionObject *Session) CheckStatus(sessionToken string) (SessionData, error)
CheckStatus accepts a session token, and returns the session object, along with an error, if any
func (*Session) DeleteSession ¶ added in v1.0.1
DeleteSession deletes the session with the specific sessionToken and returns an error, if any.
func (*Session) FetchAllSessions ¶ added in v1.0.1
func (sessionObject *Session) FetchAllSessions() ([]SessionData, error)
FetchAllSessions returns all the live sessions.
func (*Session) FetchSessionData ¶ added in v1.0.1
func (sessionObject *Session) FetchSessionData(session SessionData) (SessionData, error)
FetchSessionData returns the data of the particular session token
func (*Session) NewSession ¶ added in v1.0.1
func (sessionObject *Session) NewSession(key string, ipAddress string) (SessionData, error)
NewSession accepts the key to encode, along with the client's IP Address, inserts into the sessions table, sets the delete session timer, and returns a SessionData struct.
type SessionData ¶ added in v1.0.1
type SessionData struct {
// ID stores the bigserial (PostgreSQL row id) associated with this session
ID int64 `json:"id,omitempty"`
// Key stores the string that needs to be encoded/hashed to generate a unique session value
Key string `json:"key,omitempty"`
// Token stores the computed token using the key
Token string `json:"token,omitempty"`
// ExpiryIn stores the number of seconds after which this session will expire
ExpiryIn int64 `json:"expiry_in,omitempty"`
// ExpiresAt stores the timestamp (with full timezone) at which this session will expire
ExpiresAt time.Time `json:"expires_at,omitempty"`
// IP stores the IP address of the client requesting a new session
IP string `json:"ip,omitempty"`
// Active stores whether this session is active
Active bool `json:"active,omitempty"`
// Timestamp stores the timestamp in epoch secs when this entry was created
Timestamp int64 `json:"timestamp,omitempty"`
}
SessionData stores the parameters in the sessions table