MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / requireBasicAuth

Function requireBasicAuth

auth/common.go:23–47  ·  view source on GitHub ↗
(ctx context.Context, wr http.ResponseWriter, req *http.Request, hidden_domain string, next Auth)

Source from the content-addressed store, hash-verified

21}
22
23func requireBasicAuth(ctx context.Context, wr http.ResponseWriter, req *http.Request, hidden_domain string, next Auth) (string, bool) {
24 if hidden_domain != "" {
25 if matchHiddenDomain(req.URL.Host, hidden_domain) ||
26 matchHiddenDomain(req.Host, hidden_domain) {
27 wr.Header().Set("Proxy-Authenticate", BASIC_REALM_MSG)
28 http.Error(wr, AUTH_REQUIRED_MSG, http.StatusProxyAuthRequired)
29 return "", false
30 }
31
32 if next != nil {
33 return next.Validate(ctx, wr, req)
34 }
35
36 http.Error(wr, BAD_REQ_MSG, http.StatusBadRequest)
37 return "", false
38 }
39
40 if next != nil {
41 return next.Validate(ctx, wr, req)
42 }
43
44 wr.Header().Set("Proxy-Authenticate", BASIC_REALM_MSG)
45 http.Error(wr, AUTH_REQUIRED_MSG, http.StatusProxyAuthRequired)
46 return "", false
47}
48
49func tryValid(auth Auth, logger *clog.CondLogger, user, password, userAddr string) bool {
50 if auth == nil {

Callers 3

ValidateMethod · 0.85
ValidateMethod · 0.85
ValidateMethod · 0.85

Calls 4

matchHiddenDomainFunction · 0.85
ValidateMethod · 0.65
SetMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected