middleware

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCSRFCookieMissing = errors.New("csrf cookie token missing")
	ErrCSRFTokenMissing  = errors.New("csrf token missing in request")
	ErrCSRFTokenInvalid  = errors.New("csrf token invalid")
)

Functions

func RedirectIfAuthenticated

func RedirectIfAuthenticated(sessionService *session.Service, now func() time.Time) func(http.Handler) http.Handler

func RequestLogger

func RequestLogger(logger *slog.Logger) func(http.Handler) http.Handler

func RequireAPIAccessAuth

func RequireAPIAccessAuth(sessionSvc *session.Service, audience token.Audience, now func() time.Time) func(http.Handler) http.Handler

func RequireAPICSRF

func RequireAPICSRF(next http.Handler) http.Handler

func RequireAccessAuthWithRefresh

func RequireAccessAuthWithRefresh(
	sessionSvc *session.Service,
	audience token.Audience,
	accessTTL time.Duration,
	refreshTTL time.Duration,
	now func() time.Time,
) func(http.Handler) http.Handler

RequirePageAccessAuthWithRefresh protects Authara-rendered pages + HTMX actions. It validates the access token, and if it's missing/expired it will try to refresh using the refresh token cookie. If refresh fails, it redirects to login.

func RequireAdmin

func RequireAdmin(next http.Handler) http.Handler

func RequireCSRF

func RequireCSRF(next http.Handler) http.Handler

func ReturnTo

func ReturnTo(next http.Handler) http.Handler

Types

This section is empty.

Jump to

Keyboard shortcuts

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