MCPcopy
hub / github.com/dgraph-io/dgraph / adminAuthHandler

Function adminAuthHandler

dgraph/cmd/alpha/admin.go:53–63  ·  view source on GitHub ↗

adminAuthHandler does some standard checks for admin endpoints. It returns if something is wrong. Otherwise, it lets the given handler serve the request.

(next http.Handler)

Source from the content-addressed store, hash-verified

51// adminAuthHandler does some standard checks for admin endpoints.
52// It returns if something is wrong. Otherwise, it lets the given handler serve the request.
53func adminAuthHandler(next http.Handler) http.Handler {
54 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
55 if !hasPoormansAuth(r) {
56 x.AddCorsHeaders(w)
57 x.SetStatus(w, x.ErrorUnauthorized, "Invalid X-Dgraph-AuthToken")
58 return
59 }
60
61 next.ServeHTTP(w, r)
62 })
63}
64
65func getAdminMux() *http.ServeMux {
66 adminMux := http.NewServeMux()

Callers 2

getAdminMuxFunction · 0.85
setupServerFunction · 0.85

Calls 4

AddCorsHeadersFunction · 0.92
SetStatusFunction · 0.92
ServeHTTPMethod · 0.80
hasPoormansAuthFunction · 0.70

Tested by

no test coverage detected