session

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKey string = "phx_session_auth"

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Id      Id
	User    User
	Timeout time.Time
}

func (Entry) IsValid

func (entry Entry) IsValid() bool

type Id

type Id string

type Manager

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

func NewInMemoryManager

func NewInMemoryManager(hasher core.Hasher, duration time.Duration, cypher core.Cypher) *Manager

func NewManager

func NewManager(store SessionStore, hasher core.Hasher, duration time.Duration, cypher core.Cypher) *Manager

func (*Manager) Add

func (manager *Manager) Add(user User) Entry

func (*Manager) CreateSessionCookie

func (manager *Manager) CreateSessionCookie(w http.ResponseWriter, user User)

func (*Manager) Delete

func (manager *Manager) Delete(id Id)

func (*Manager) DestroySession

func (manager *Manager) DestroySession(w http.ResponseWriter, req *http.Request) error

func (*Manager) Get

func (manager *Manager) Get(id Id) (Entry, error)

func (*Manager) GetUserIfValid

func (manager *Manager) GetUserIfValid(id Id) (User, error)

func (*Manager) ReadSessionCookie

func (manager *Manager) ReadSessionCookie(req *http.Request) (User, error)

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Delete

func (store *MemoryStore) Delete(id Id)

func (*MemoryStore) Get

func (store *MemoryStore) Get(id Id) (Entry, error)

func (*MemoryStore) Save

func (store *MemoryStore) Save(entry Entry)

type SessionStore

type SessionStore interface {
	Save(entry Entry)
	Get(id Id) (Entry, error)
	Delete(id Id)
}

type User

type User struct {
	Id    int64
	Name  string
	Role  core.Role
	Image string
}

Jump to

Keyboard shortcuts

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