From c1f85305fe864a2c258d97c7576116ff5615cadf Mon Sep 17 00:00:00 2001 From: Jesse Peterson Date: Mon, 4 Apr 2022 09:23:46 -0700 Subject: [PATCH] Rename handler --- cmd/nanomdm/main.go | 8 ++++---- http/http.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/nanomdm/main.go b/cmd/nanomdm/main.go index fe0f108..bb997ce 100644 --- a/cmd/nanomdm/main.go +++ b/cmd/nanomdm/main.go @@ -159,7 +159,7 @@ func main() { // register API handler for push cert storage/upload. var pushCertHandler http.Handler pushCertHandler = mdmhttp.StorePushCertHandlerFunc(mdmStorage, logger.With("handler", "store-cert")) - pushCertHandler = mdmhttp.BasicAuth(pushCertHandler, apiUsername, *flAPIKey, "nanomdm") + pushCertHandler = mdmhttp.BasicAuthMiddleware(pushCertHandler, apiUsername, *flAPIKey, "nanomdm") mux.Handle(endpointAPIPushCert, pushCertHandler) // register API handler for push notifications. @@ -167,7 +167,7 @@ func main() { var pushHandler http.Handler pushHandler = mdmhttp.PushHandlerFunc(pushService, logger.With("handler", "push")) pushHandler = http.StripPrefix(endpointAPIPush, pushHandler) - pushHandler = mdmhttp.BasicAuth(pushHandler, apiUsername, *flAPIKey, "nanomdm") + pushHandler = mdmhttp.BasicAuthMiddleware(pushHandler, apiUsername, *flAPIKey, "nanomdm") mux.Handle(endpointAPIPush, pushHandler) // register API handler for new command queueing. @@ -175,7 +175,7 @@ func main() { var enqueueHandler http.Handler enqueueHandler = mdmhttp.RawCommandEnqueueHandler(mdmStorage, pushService, logger.With("handler", "enqueue")) enqueueHandler = http.StripPrefix(endpointAPIEnqueue, enqueueHandler) - enqueueHandler = mdmhttp.BasicAuth(enqueueHandler, apiUsername, *flAPIKey, "nanomdm") + enqueueHandler = mdmhttp.BasicAuthMiddleware(enqueueHandler, apiUsername, *flAPIKey, "nanomdm") mux.Handle(endpointAPIEnqueue, enqueueHandler) if *flMigration { @@ -189,7 +189,7 @@ func main() { // migrate MDM enrollments between servers. var migHandler http.Handler migHandler = mdmhttp.CheckinHandlerFunc(nano, logger.With("handler", "migration")) - migHandler = mdmhttp.BasicAuth(migHandler, apiUsername, *flAPIKey, "nanomdm") + migHandler = mdmhttp.BasicAuthMiddleware(migHandler, apiUsername, *flAPIKey, "nanomdm") mux.Handle(endpointAPIMigration, migHandler) } } diff --git a/http/http.go b/http/http.go index e7966ab..08a650f 100644 --- a/http/http.go +++ b/http/http.go @@ -20,8 +20,8 @@ func ReadAllAndReplaceBody(r *http.Request) ([]byte, error) { return b, nil } -// BasicAuth is a simple HTTP plain authentication middleware. -func BasicAuth(next http.Handler, username, password, realm string) http.HandlerFunc { +// BasicAuthMiddleware is a simple HTTP plain authentication middleware. +func BasicAuthMiddleware(next http.Handler, username, password, realm string) http.HandlerFunc { uBytes := []byte(username) pBytes := []byte(password) return func(w http.ResponseWriter, r *http.Request) {