session

package
v0.0.0-...-3a75ae7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 15 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](driver driver.Driver, config ...func(*Config)) strategy.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(driver driver.Driver, 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