middleware

package
v0.0.0-...-f70499c Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthCookie        = "chitchat-session"
	RequestedURLParam = "requested-url"
)

Variables

This section is empty.

Functions

func DeleteSessionCookie

func DeleteSessionCookie(w http.ResponseWriter, r *http.Request)

func ExtractAllowedSearchParams

func ExtractAllowedSearchParams(u *url.URL) url.Values

func GetSessionID

func GetSessionID(r *http.Request) (string, error)

func RequestLogger

func RequestLogger(next http.Handler) http.Handler

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, r *http.Request, session model.Session)

Types

type Auth

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

func NewAuthMiddleware

func NewAuthMiddleware(userManager UserManager, sessionManager SessionManager) Auth

func (Auth) RedirectIfLoggedIn

func (m Auth) RedirectIfLoggedIn(location string) func(next http.Handler) http.Handler

func (Auth) RequireAuthenticatedUser

func (m Auth) RequireAuthenticatedUser(next http.Handler) http.Handler

type SessionManager

type SessionManager interface {
	FindByIdAndMarkSeen(id string) (model.Session, error)
}

type UserManager

type UserManager interface {
	FindByUUID(uuid string) (model.User, error)
}

Jump to

Keyboard shortcuts

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