MCPcopy
hub / github.com/perkeep/perkeep / RequireAuth

Function RequireAuth

pkg/auth/auth.go:434–442  ·  view source on GitHub ↗

RequireAuth wraps a function with another function that enforces HTTP Basic Auth and checks if the operations in op are all permitted.

(h http.Handler, op Operation)

Source from the content-addressed store, hash-verified

432// RequireAuth wraps a function with another function that enforces
433// HTTP Basic Auth and checks if the operations in op are all permitted.
434func RequireAuth(h http.Handler, op Operation) http.Handler {
435 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
436 if Allowed(req, op) {
437 h.ServeHTTP(rw, req)
438 } else {
439 SendUnauthorized(rw, req)
440 }
441 })
442}
443
444var (
445 processRand string

Callers 2

makeCamliHandlerFunction · 0.92
InstallHandlersMethod · 0.92

Calls 3

AllowedFunction · 0.85
SendUnauthorizedFunction · 0.85
ServeHTTPMethod · 0.45

Tested by

no test coverage detected