Documentation
¶
Overview ¶
Package middleware holds HTTP middleware; handlers live in package handler.
Index ¶
- func Admin(log zerolog.Logger) func(http.Handler) http.Handler
- func Authenticate(a Authenticator, log zerolog.Logger, next http.Handler) http.Handler
- func CSRF(log zerolog.Logger, next http.Handler) http.Handler
- func Headers(next http.Handler) http.Handler
- func Proxy(trusted []netip.Prefix, next http.Handler) http.Handler
- func Read(public bool, log zerolog.Logger) func(http.Handler) http.Handler
- type Authenticator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Admin ¶
Admin lets a request through only with an admin session or token (spec 10: the only role is admin).
func Authenticate ¶
Authenticate attaches the principal of a valid session cookie or API token to the request. A bad token is answered with 401; a stale cookie is ignored (anonymous). The WebSocket upgrade may carry the token as ?token= (spec 9.3).
func CSRF ¶
CSRF rejects state-changing requests whose Origin (or Referer) is not this host (spec 10). Requests without either are only allowed with a bearer token, which a browser never adds on its own.