sessions

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CookieName = "salmon_session"
	TTL        = 12 * time.Hour
)

Variables

View Source
var (
	ErrSessionExpired = errors.New("session expired")
	ErrNoSession      = errors.New("no session")
)
View Source
var SecureCookies = true

SecureCookies controls the Secure attribute of the session cookie. It is only ever turned off for plain-http local development (see server.New).

Functions

func ClearCookie

func ClearCookie(w http.ResponseWriter)

ClearCookie tells the browser to drop the session cookie.

func Create

func Create(ctx context.Context, db *gorm.DB, in Input) (string, *schema.Session, error)

Create establishes a new authenticated session. The returned string is the raw cookie value; only its digest is persisted, so a database dump does not hand over live sessions.

func Get

func Get(ctx context.Context, db *gorm.DB, r *http.Request) (*schema.Session, error)

func Purge

func Purge(ctx context.Context, db *gorm.DB) error

Purge permanently removes sessions that expired or were revoked more than a day ago.

func Revoke

func Revoke(ctx context.Context, db *gorm.DB, r *http.Request) error

Revoke invalidates the session identified by the request's cookie, if any.

func SetCookie

func SetCookie(w http.ResponseWriter, raw string, expires time.Time)

Types

type Input

type Input struct {
	TokenDigest string
	Subject     string
	AuthTime    time.Time
	AMR         []string
	IDP         string
}

Jump to

Keyboard shortcuts

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