sessions

package
v2.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMiddleware

func CheckMiddleware(next http.Handler) http.Handler

func Set added in v2.2.0

func Set(newConfig ConfigStruct)

func SetNewSessionCookie

func SetNewSessionCookie(res http.ResponseWriter, req *http.Request, username string) (newSession *session.Session)

SetNewSessionCookie create a new session and store it as cookie in r

Types

type ConfigStruct

type ConfigStruct struct {
	Timeout   time.Duration `yaml:"timeout"`   // defaults to 60
	Intervall time.Duration `yaml:"intervall"` // defaults to 90
}

func (*ConfigStruct) MarshalZerologObject added in v2.2.0

func (c *ConfigStruct) MarshalZerologObject(e *zerolog.Event)

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Define our struct

func (*Middleware) CheckMiddleware added in v2.4.0

func (mdw *Middleware) CheckMiddleware(next http.Handler) http.Handler

provide a middleware that check if your session is valid

This inject the session into your request-context and can be received with session.FromContext()

func (*Middleware) DeRegister

func (mdw *Middleware) DeRegister(sessionID string)

DeRegister close and remove an session

This function do not LOCK the sessionlist

func (*Middleware) GetAllSessionInfos

func (middleware *Middleware) GetAllSessionInfos() (infos []session.SessionInfo)

func (*Middleware) GetSessionInfos

func (middleware *Middleware) GetSessionInfos(username string) (infos []session.SessionInfo)

GetSessionInfos return all sessions for an given user

func (*Middleware) HookOnFail added in v2.4.0

func (mdw *Middleware) HookOnFail(hook func(req *http.Request))

func (*Middleware) HookOnSuccess added in v2.4.0

func (mdw *Middleware) HookOnSuccess(hook func(req *http.Request))

func (*Middleware) Init

func (mdw *Middleware) Init()

func (Middleware) Name

func (mdw Middleware) Name() string

func (*Middleware) PublishToAll

func (middleware *Middleware) PublishToAll(msg *message.Message)

func (*Middleware) Set added in v2.2.0

func (mdw *Middleware) Set(newConfig ConfigStruct)

func (*Middleware) SetCheckIntervall

func (mdw *Middleware) SetCheckIntervall(intervall time.Duration)

SetCheckInterval set the intervall for check of sessions

func (*Middleware) SetNewSessionCookie added in v2.5.1

func (mdw *Middleware) SetNewSessionCookie(res http.ResponseWriter, req *http.Request, username string) (newSession *session.Session)

SetNewSessionCookie create a new session and store it as cookie in r

func (*Middleware) SetTimeout

func (mdw *Middleware) SetTimeout(timeout time.Duration)

SetTimeout will set the timeout for an existing session the session will be removed after timeout when no action is performed by the user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL