MCPcopy Create free account
hub / github.com/coder/envbuilder / BasicAuthMW

Function BasicAuthMW

testutil/mwtest/auth_basic.go:5–18  ·  view source on GitHub ↗
(username, password string)

Source from the content-addressed store, hash-verified

3import "net/http"
4
5func BasicAuthMW(username, password string) func(http.Handler) http.Handler {
6 return func(next http.Handler) http.Handler {
7 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
8 if username != "" || password != "" {
9 authUser, authPass, ok := r.BasicAuth()
10 if !ok || username != authUser || password != authPass {
11 w.WriteHeader(http.StatusUnauthorized)
12 return
13 }
14 }
15 next.ServeHTTP(w, r)
16 })
17 }
18}

Callers 4

setupInMemoryRegistryFunction · 0.92
TestCloneRepoFunction · 0.92
TestShallowCloneRepoFunction · 0.92
CreateGitServerFunction · 0.92

Calls

no outgoing calls

Tested by 3

setupInMemoryRegistryFunction · 0.74
TestCloneRepoFunction · 0.74
TestShallowCloneRepoFunction · 0.74