sessionkit

package
v0.0.0-...-9e9b37c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ResultExpired = Result(3)
View Source
const ResultInvalid = Result(2)
View Source
const ResultMaxTries = Result(4)
View Source
const ResultValid = Result(1)

Variables

View Source
var CookieDomain string
View Source
var SecretBytes []byte

Functions

func BrowserClientInfo

func BrowserClientInfo(c *web.Context) string

func BrowserCookieUserID

func BrowserCookieUserID(c *web.Context) int64

func BrowserID

func BrowserID(c *web.Context) []byte

func GetPasswordContainer

func GetPasswordContainer(password string) []byte

func TokenUserID

func TokenUserID(token []byte) int64

func ValidPasswordForContainer

func ValidPasswordForContainer(container []byte, password string) bool

Types

type Result

type Result int

type Session

type Session struct {
	Token      []byte `protobuf:"1"`
	ClientInfo string `protobuf:"2"` // could be: user-agent, sdk version, app version, ...
	DeviceID   []byte `protobuf:"10,opt"`
	LastIP     []byte `protobuf:"11,opt"`
	LastAccess int64  `protobuf:"12,opt"`
	Created    int64  `protobuf:"13,opt"`
	//utc_offset INT8 NOT NULL DEFAULT 0:::INT,
	// push
	IOSPushToken        []byte `protobuf:"51,opt"`
	GooglePlayPushToken []byte `protobuf:"52,opt"`
}

func (*Session) CreatedTime

func (s *Session) CreatedTime() time.Time

func (*Session) DeviceIDHex

func (s *Session) DeviceIDHex() string

func (*Session) LastAccessTime

func (s *Session) LastAccessTime() time.Time

func (*Session) LastIPNet

func (s *Session) LastIPNet() net.IP

func (*Session) TokenHex

func (s *Session) TokenHex() string

type Sessions

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

func New

func New(sessiondata []byte) *Sessions

func (*Sessions) BrowserAccessSession

func (s *Sessions) BrowserAccessSession(c *web.Context) (bool, bool)

func (*Sessions) BrowserCreateSession

func (s *Sessions) BrowserCreateSession(c *web.Context, userID int64, permanentCookie bool)

func (*Sessions) BrowserLogout

func (s *Sessions) BrowserLogout(c *web.Context)

func (*Sessions) Bytes

func (s *Sessions) Bytes() []byte

func (*Sessions) GenerateLogincode

func (s *Sessions) GenerateLogincode(letters string, length int, expires time.Duration) string

func (*Sessions) HasPassword

func (s *Sessions) HasPassword() bool

func (*Sessions) LoginWithPassword

func (s *Sessions) LoginWithPassword(password string, maxFailedAttempts int64) Result

func (*Sessions) Sessions

func (s *Sessions) Sessions() []*Session

func (*Sessions) SetPassword

func (s *Sessions) SetPassword(password string)

func (*Sessions) TokenAccessSession

func (s *Sessions) TokenAccessSession(token []byte, clientIP net.IP) (bool, bool)

func (*Sessions) TokenCreateSession

func (s *Sessions) TokenCreateSession(userID int64, deviceID []byte, clientInfo string, clientIP net.IP) []byte

func (*Sessions) TokenGetIOSPushToken

func (s *Sessions) TokenGetIOSPushToken(token []byte) []byte

func (*Sessions) TokenLogout

func (s *Sessions) TokenLogout(token []byte)

func (*Sessions) TokenReplaceUserID

func (s *Sessions) TokenReplaceUserID(token []byte, newUserID int64) []byte

func (*Sessions) TokenSetGooglePlayPushToken

func (s *Sessions) TokenSetGooglePlayPushToken(token []byte, googlePlayPushToken []byte)

func (*Sessions) TokenSetIOSPushToken

func (s *Sessions) TokenSetIOSPushToken(token []byte, iosPushToken []byte)

func (*Sessions) ValidateLogincode

func (s *Sessions) ValidateLogincode(code string, maxTries int64) Result

Jump to

Keyboard shortcuts

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