auth

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(realm string, deps func() settings.Values) func(next http.Handler) http.Handler

BasicAuth implements a simple middleware handler for adding basic http auth to a route.

func ContextWithVisitor

func ContextWithVisitor(ctx context.Context, id uniq.Hash) context.Context

ContextWithVisitor adds visitor id to context.

func Hash

func Hash(in HashInput) string

func IsAdmin

func IsAdmin(ctx context.Context) bool

func MaybeAuth

func MaybeAuth(deps settings.Values) func(next http.Handler) http.Handler

func SetAdmin

func SetAdmin(ctx context.Context) context.Context

func VisitorFromContext

func VisitorFromContext(ctx context.Context) uniq.Hash

VisitorFromContext returns visitor hash or 0.

func VisitorMiddleware

func VisitorMiddleware(logger ctxd.Logger, cfg settings.Values) func(handler http.Handler) http.Handler

Types

type HashInput

type HashInput struct {
	Pass string `formData:"pass" format:"password"`
	Salt Salt   `formData:"salt"`
}

type Salt

type Salt string

func (Salt) PrepareJSONSchema

func (m Salt) PrepareJSONSchema(schema *jsonschema.Schema) error

type Visitor

type Visitor struct {
	uniq.Head
	Latest      time.Time `db:"latest"`
	Hits        int       `db:"hits"`
	UserAgent   string    `db:"user_agent"`
	Referrer    string    `db:"referrer"`
	Destination string    `db:"destination"`
	RemoteAddr  string    `db:"remote_addr"`
}

Jump to

Keyboard shortcuts

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