MCPcopy
hub / github.com/perkeep/perkeep / AllowedAccess

Method AllowedAccess

pkg/auth/auth.go:303–329  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

301}
302
303func (da *DevAuth) AllowedAccess(req *http.Request) Operation {
304 _, pass, err := httputil.BasicAuth(req)
305 if err == nil {
306 if pass == da.Password {
307 return OpAll
308 }
309 if da.VivifyPass != nil && pass == *da.VivifyPass {
310 return OpVivify
311 }
312 }
313
314 if authTokenHeaderMatches(req) {
315 return OpAll
316 }
317 if websocketTokenMatches(req) {
318 return OpAll
319 }
320
321 // See if the local TCP port is owned by the same non-root user as this
322 // server. This check performed last as it may require reading from the
323 // kernel or exec'ing a program.
324 if httputil.IsLocalhost(req) {
325 return OpAll
326 }
327
328 return 0
329}
330
331func (da *DevAuth) AddAuthHeader(req *http.Request) {
332 req.SetBasicAuth("", da.Password)

Callers

nothing calls this directly

Calls 4

BasicAuthFunction · 0.92
IsLocalhostFunction · 0.92
authTokenHeaderMatchesFunction · 0.85
websocketTokenMatchesFunction · 0.85

Tested by

no test coverage detected