websession

package
v0.0.0-...-91c01a0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptedStorage

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

EncryptedStorage -

func NewEncryptedStorage

func NewEncryptedStorage(privatekey string) *EncryptedStorage

NewEncryptedStorage -

func (*EncryptedStorage) Decrypt

func (en *EncryptedStorage) Decrypt(enc []byte) ([]byte, error)

Decrypt -

func (*EncryptedStorage) Encrypt

func (en *EncryptedStorage) Encrypt(data []byte) ([]byte, error)

Encrypt -

type Encrypter

type Encrypter interface {
	Encrypt(data []byte) (encrypted []byte, err error)
	Decrypt(data []byte) (decrypted []byte, err error)
}

Encrypter -

type JSONSession

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

JSONSession -

func NewJSONSession

func NewJSONSession(sd Sessionstorer, encrypter Encrypter) (*JSONSession, error)

NewJSONSession -

func (*JSONSession) Commit

func (s *JSONSession) Commit(token string, b []byte, expiry time.Time) error

Commit adds a session token and data to the store with the given expiry time. If the session token already exists then the data and expiry time are updated.

func (*JSONSession) Delete

func (s *JSONSession) Delete(token string) error

Delete removes a session token and corresponding data from the store.

func (*JSONSession) Find

func (s *JSONSession) Find(token string) (b []byte, exists bool, err error)

Find returns the data for a given session token from the store. If the session token is not found or is expired, the returned exists flag will be set to false.

type Session

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

Session stores session level information

func New

func New(name string, manager *scs.SessionManager) *Session

New returns a new session cookie store.

func (*Session) CSRF

func (s *Session) CSRF(r *http.Request) bool

CSRF -

func (*Session) Logout

func (s *Session) Logout(r *http.Request)

Logout -

func (*Session) RememberMe

func (s *Session) RememberMe(r *http.Request, value bool)

RememberMe -

func (*Session) SetCSRF

func (s *Session) SetCSRF(r *http.Request) string

SetCSRF -

func (*Session) SetString

func (s *Session) SetString(r *http.Request, name string, value string)

SetString -

func (*Session) SetUser

func (s *Session) SetUser(r *http.Request, value string)

SetUser -

func (*Session) String

func (s *Session) String(r *http.Request, name string) string

String -

func (*Session) User

func (s *Session) User(r *http.Request) (string, bool)

User -

type SessionData

type SessionData struct {
	ID     string    `json:"id"`
	Data   []byte    `json:"data"`
	Expire time.Time `json:"expire"`
}

SessionData -

type SessionDatabase

type SessionDatabase struct {
	Records map[string]SessionData `json:"db"`
}

SessionDatabase -

func (*SessionDatabase) Load

func (sd *SessionDatabase) Load(ss Sessionstorer, en Encrypter) error

Load -

func (*SessionDatabase) Save

func (sd *SessionDatabase) Save(ss Sessionstorer, en Encrypter) error

Save -

type Sessionstorer

type Sessionstorer interface {
	Save([]byte) error
	Load() ([]byte, error)
}

Sessionstorer reads and writes data to an object.

Jump to

Keyboard shortcuts

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