auth

package
v0.0.0-...-56114fe Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleLogin

func HandleLogin(d *storage.Database) func(http.ResponseWriter, *http.Request)

HandleLogin returns a handler that implements logging into the application.

func HandleLogout

func HandleLogout(w http.ResponseWriter, _ *http.Request)

HandleLogout handles logging out of the application. NOTE: This is not yet implemented.

func VerifyCookie

func VerifyCookie(d *storage.Database, r *http.Request) (models.User, error)

VerifyCookie checks a request for an auth cookie and authenticates it against the database.

Types

type Middleware

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

Middleware is a wrapper around a http.Handler that contains a pointer to the database connection.

func WithAuth

func WithAuth(h http.Handler, d *storage.Database, root string, redirector Redirector) Middleware

WithAuth returns a Middleware that checks authentication before forwarding requests to the given handler.

func (Middleware) ServeHTTP

func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface and checks authentication on each request.

type Redirector

type Redirector = func(http.ResponseWriter, *http.Request)

Redirector is the type of a custom HTTP handler to be called upon failed cookie verification.

Jump to

Keyboard shortcuts

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