middleware

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SessionCookieName = "session"

Variables

This section is empty.

Functions

func CSRFProtect

func CSRFProtect(secretKey []byte, secure bool) func(http.Handler) http.Handler

func CSRFToken

func CSRFToken(r *http.Request) string

func ClearSessionCookie

func ClearSessionCookie(w http.ResponseWriter, secure bool)

func ContextWithClaims

func ContextWithClaims(ctx context.Context, claims *token.SessionClaims) context.Context

func ContextWithUserProfile

func ContextWithUserProfile(ctx context.Context, user *models.User) context.Context

func IsHTTPS

func IsHTTPS(baseURL string) bool

IsHTTPS reports whether baseURL uses the https scheme.

func JWTAuth

func JWTAuth(tokens *token.Tokens, secureCookies bool) func(http.Handler) http.Handler

func LoadUserProfile

func LoadUserProfile(db *bun.DB) func(http.Handler) http.Handler

func RequireAuth

func RequireAuth(next http.Handler) http.Handler

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, token string, secure bool)

func UserFromContext

func UserFromContext(ctx context.Context) *token.SessionClaims

func UserProfileFromContext

func UserProfileFromContext(ctx context.Context) *models.User

Types

type ContextKey

type ContextKey string
const UserKey ContextKey = "user"
const UserProfileKey ContextKey = "user_profile"

Jump to

Keyboard shortcuts

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