Help us shape the future of Go! Take the 2026 Go Developer Survey

adminsession

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSession = errors.New("invalid admin session")

Functions

This section is empty.

Types

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Create

func (s *MemoryStore) Create(ctx context.Context, session *Session) error

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(ctx context.Context, hash string) error

func (*MemoryStore) DeleteExpired

func (s *MemoryStore) DeleteExpired(ctx context.Context, now time.Time, limit int) (int64, error)

func (*MemoryStore) ExtendActive

func (s *MemoryStore) ExtendActive(ctx context.Context, hash string, now, expiresAt time.Time) (bool, error)

func (*MemoryStore) GetActive

func (s *MemoryStore) GetActive(ctx context.Context, hash string, now time.Time) (*Session, error)

type Session

type Session struct {
	bun.BaseModel `bun:"table:admin_sessions,alias:admin_session"`
	SessionIDHash string    `bun:"session_id_hash,pk,type:text"`
	CreatedAt     time.Time `bun:"created_at,notnull"`
	ExpiresAt     time.Time `bun:"expires_at,notnull"`
}

func (Session) Valid

func (s Session) Valid() bool

type Store

type Store interface {
	Create(context.Context, *Session) error
	GetActive(context.Context, string, time.Time) (*Session, error)
	ExtendActive(context.Context, string, time.Time, time.Time) (bool, error)
	Delete(context.Context, string) error
	DeleteExpired(context.Context, time.Time, int) (int64, error)
}

Jump to

Keyboard shortcuts

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