Skip to content

Commit

Permalink
Rename handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Apr 4, 2022
1 parent 3faeabe commit c1f8530
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/nanomdm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,23 @@ 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.
// we strip the prefix to use the path as an id.
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.
// we strip the prefix to use the path as an id.
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 {
Expand All @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c1f8530

Please sign in to comment.