Documentation ¶
Index ¶
- type Session
- func (s *Session) AddToContext(ctx context.Context) (newCtx context.Context)
- func (s *Session) AuthenticatedSet(authenticated bool)
- func (s *Session) Close()
- func (s *Session) CloseChannel()
- func (s *Session) Data(name string) (data interface{}, err error)
- func (s *Session) DataSet(name string, data interface{}) (err error)
- func (s Session) ID() string
- func (s *Session) IDSet(newID string)
- func (s *Session) InternalSet()
- func (s Session) IsAuthenticated() bool
- func (s Session) IsInternal() bool
- func (s Session) IsTimedOut(timeout time.Duration) bool
- func (s *Session) JWTNew() (signedToken []byte, err error)
- func (s *Session) JWTVerify(signedToken []byte) (valid bool)
- func (s Session) MarshalZerologObject(event *zerolog.Event)
- func (s *Session) Refresh()
- func (s *Session) Reset(remoteAddr string)
- func (s *Session) Send(msg *message.Message)
- func (s Session) SessionInfo() (info SessionInfo)
- func (s *Session) ToFrontend() <-chan *message.Message
- func (s Session) Username() (username string)
- func (s *Session) UsernameSet(username string)
- type SessionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represent a single session
func FromContext ¶
FromContext return the session from an context this works only if it was added before with AddToContext
func (*Session) AddToContext ¶
AddToContext will add the session to the given context and return the new context
func (*Session) AuthenticatedSet ¶
AuthenticatedSet can set the authenticated-state to true/false ONLY ONCE
you can set it to false every time
but if its set to false, you can not set it to true again
func (*Session) InternalSet ¶
func (s *Session) InternalSet()
InternalSet mark this session as internal session
This is for internal stuff, like config changes on the hard drive or shutdown etc.
This should NEVER set when it comes from external request
func (Session) IsAuthenticated ¶
func (Session) IsInternal ¶
func (*Session) JWTNew ¶
NewJWTToken
- store the sessionID in JWT-Token
- create new secret ( and overwrite an possible old secret !)
- create and sign the jwt
func (Session) MarshalZerologObject ¶
MarshalZerologObject implementation to use it with Object()
func (*Session) Reset ¶
Init just init an existing session to initial state
All data gets lost !
remoteAddr can be empty
func (*Session) Send ¶
Send will send an msg over server-sent-events ( if an client connected to it )
func (Session) SessionInfo ¶
func (s Session) SessionInfo() (info SessionInfo)
GetSessionInfos return all sessions for an given user
func (*Session) ToFrontend ¶
return the channel
func (*Session) UsernameSet ¶
type SessionInfo ¶
type SessionInfo struct { ID string `json:"id,omitempty"` CreatedAt time.Time `json:"timestamp,omitempty"` // when the session was created UpdatedAt time.Time `json:"updated,omitempty"` // when the session was created Username string `json:"username,omitempty"` // the username or "" if anonym RemoteAddr string `json:"ip,omitempty"` }
SessionInfo represent information about a single session