sessions

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySessions = "Api.Sessions"
)

Variables

View Source
var (
	ErrInvalidDuration   = errors.New("Invalid Duration")
	ErrInvalidUserID     = errors.New("Invalid UserID")
	ErrInvalidRemoteAddr = errors.New("Invalid RemoteAddr")
	ErrRemoteAddrChanged = errors.New("RemoteAddr Changed")
	ErrInvalidSessionID  = errors.New("Invalid SessionID")
	ErrSessionExpired    = errors.New("Session Expired")
	ErrEncode            = errors.New("Encode Error")
	ErrDecode            = errors.New("Decode Error")
	ErrCache             = errors.New("Cache Error")
)
View Source
var (
	ErrInternalError = errors.New("Internal Error")
)

Functions

func IsSessionValid added in v0.0.2

func IsSessionValid(sessionID SessionID) bool

func IsUserValid

func IsUserValid(userID uint64) bool

func VerifySession added in v0.0.2

func VerifySession(ctx context.Context, subject string, message *bank.Message) (*bank.Message, error)

Types

type Session

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

func ContextSession added in v0.0.2

func ContextSession(ctx context.Context) (*Session, error)

func NewSession

func NewSession(ctx context.Context) *Session

func (*Session) CreateSession

func (s *Session) CreateSession(ctx context.Context, userID uint64, remoteAddr string, duration time.Duration) (SessionID, error)

func (*Session) ExtendSession

func (s *Session) ExtendSession(ctx context.Context, remoteAddr string, sessionID SessionID, duration time.Duration) (uint64, error)

func (*Session) InvalidateSession

func (s *Session) InvalidateSession(ctx context.Context, sessionID SessionID) error

func (*Session) IsSessionValid

func (s *Session) IsSessionValid(ctx context.Context, sessionID SessionID) bool

func (*Session) UserSession

func (s *Session) UserSession(ctx context.Context, sessionID SessionID) uint64

type SessionID

type SessionID string

func NewSessionID

func NewSessionID() SessionID

type SessionInfo

type SessionInfo struct {
	UserID     uint64
	RemoteAddr string
	SessionID  SessionID
	Expiration time.Time
}

func (*SessionInfo) Decode

func (s *SessionInfo) Decode(data []byte) error

Decode return SessionInfo from bytes. Decoded with gob

func (*SessionInfo) Encode

func (s *SessionInfo) Encode() ([]byte, error)

Encode return bytes from Message. Encoded with gob

func (*SessionInfo) Expired

func (s *SessionInfo) Expired() bool

Jump to

Keyboard shortcuts

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