Documentation
¶
Overview ¶
Package basesession implements the session management for the application.
Index ¶
- type BaseSession
- func (s *BaseSession) Authenticated() http.HandlerFunc
- func (s *BaseSession) Logout() http.HandlerFunc
- func (s *BaseSession) SetXSRFToken(next http.Handler) http.Handler
- func (s *BaseSession) StartSession(next http.Handler) http.Handler
- func (s *BaseSession) StartSessionAPI(ctx context.Context, w http.ResponseWriter, r *http.Request) (context.Context, error)
- func (s *BaseSession) ValidateSession(next http.Handler) http.Handler
- func (s *BaseSession) ValidateSessionAPI(ctx context.Context) (context.Context, error)
- func (s *BaseSession) ValidateXSRFToken(next http.Handler) http.Handler
- type Handlers
- type LogHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseSession ¶
type BaseSession struct {
SessionTimeout time.Duration
Handle LogHandler
Storage sessionstorage.BaseStore
CookieHandler internalcookie.Handler
}
BaseSession implements the shared features for all session implementations
func (*BaseSession) Authenticated ¶
func (s *BaseSession) Authenticated() http.HandlerFunc
Authenticated is the handler reports if the session is authenticated
func (*BaseSession) Logout ¶
func (s *BaseSession) Logout() http.HandlerFunc
Logout destroys the current session
func (*BaseSession) SetXSRFToken ¶
func (s *BaseSession) SetXSRFToken(next http.Handler) http.Handler
SetXSRFToken sets the XSRF Token
func (*BaseSession) StartSession ¶
func (s *BaseSession) StartSession(next http.Handler) http.Handler
StartSession initializes a session by restoring it from a cookie, or if that fails, initializing a new session. The session cookie is then updated and the sessionID is inserted into the context.
func (*BaseSession) StartSessionAPI ¶ added in v0.7.0
func (s *BaseSession) StartSessionAPI(ctx context.Context, w http.ResponseWriter, r *http.Request) (context.Context, error)
StartSessionAPI exposes the internals of the StartSession Handler for use with the API interface
func (*BaseSession) ValidateSession ¶
func (s *BaseSession) ValidateSession(next http.Handler) http.Handler
ValidateSession checks the sessionID in the database to validate that it has not expired and updates the last activity timestamp if it is still valid. StartSession handler must be called before calling ValidateSession
func (*BaseSession) ValidateSessionAPI ¶ added in v0.7.0
ValidateSessionAPI checks the session cookie and if it is valid, stores the session data into the context
func (*BaseSession) ValidateXSRFToken ¶
func (s *BaseSession) ValidateXSRFToken(next http.Handler) http.Handler
ValidateXSRFToken validates the XSRF Token
type Handlers ¶
type Handlers interface {
Authenticated() http.HandlerFunc
Logout() http.HandlerFunc
StartSession(next http.Handler) http.Handler
ValidateSession(next http.Handler) http.Handler
SetXSRFToken(next http.Handler) http.Handler
ValidateXSRFToken(next http.Handler) http.Handler
}
Handlers defines the interface for session handlers used by all session implementations
type LogHandler ¶
type LogHandler func(handler func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc
LogHandler defines the handler signature required for handling logs.