session

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package session implements a cookie-backed auth.Authenticator: it reads the session cookie, resolves its hashed token to a live session and user, and returns the corresponding auth.Principal. Issuance/revocation live in the auth REST handler; this package only reads.

Index

Constants

View Source
const DefaultCookieName = "sqi_session"

DefaultCookieName is the session cookie name.

Variables

View Source
var ErrNoCredential = errors.New("session: no credential")

ErrNoCredential means the request carried no session cookie.

Functions

This section is empty.

Types

type Authenticator

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

Authenticator resolves a session cookie to a Principal.

func New

func New(src SessionSource, cookieName string, clock func() time.Time) *Authenticator

New returns a session Authenticator. A nil clock defaults to time.Now.

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(r *http.Request) (auth.Principal, error)

Authenticate implements auth.Authenticator.

type SessionSource

type SessionSource interface {
	GetSessionUserByTokenHash(ctx context.Context, tokenHash string, now time.Time) (store.User, error)
}

SessionSource is the store surface the authenticator needs.

Jump to

Keyboard shortcuts

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