session

package
v0.0.0-...-eb73c4f Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCookieName = "usid"
	DefaultExpiresIn  = time.Hour * 12
)

Functions

func New

func New[T any](pool *pgxpool.Pool, opts ...func(*Config)) shieldstrategy.Authenticator[T]

New creates a new session authenticator.

The sesion authenticator uses a DB to store sessions and a cookie to store the session ID.

Types

type Config

type Config struct {
	Logger *slog.Logger

	CookieName string        // optinal (default: "usid")
	ExpiresIn  time.Duration // optinal (default: 12h)
}

type LogoutHandler

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

LogoutHandler is a handler that logs out the user and deletes the session.

func NewLogoutHandler

func NewLogoutHandler(pool *pgxpool.Pool, config *Config) *LogoutHandler

func (*LogoutHandler) HandleLogout

func (h *LogoutHandler) HandleLogout(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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