From 9c9b4c651d02e52994ebd7cde45bc70be598bd1b Mon Sep 17 00:00:00 2001 From: Dmitry Rubtsov Date: Mon, 25 Nov 2024 15:57:53 +0600 Subject: [PATCH] small fixes --- cmd/keenetic-auth-gw/main.go | 4 ++-- internal/entrypoint/middleware.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/keenetic-auth-gw/main.go b/cmd/keenetic-auth-gw/main.go index f4c4992..638e401 100644 --- a/cmd/keenetic-auth-gw/main.go +++ b/cmd/keenetic-auth-gw/main.go @@ -83,13 +83,13 @@ func startServersAction(c *cli.Context) error { func startServer(dm *device.DeviceManager, entryCfg config.EntrypointConfig, wg *sync.WaitGroup) { defer wg.Done() - device, ok := dm.GetDeviceByTag(entryCfg.DeviceTag) + d, ok := dm.GetDeviceByTag(entryCfg.DeviceTag) if !ok { log.Fatal().Msgf("%s: \"%s\" device not found", entryCfg.Listen, entryCfg.DeviceTag) } err := entrypoint.NewEntrypoint(entrypoint.EntrypointOptions{ - Device: device, + Device: d, ListenAddr: entryCfg.Listen, ForwardAuthHeader: entryCfg.ForwardedAuthHeader, BasicAuth: entryCfg.BasicAuthMap(), diff --git a/internal/entrypoint/middleware.go b/internal/entrypoint/middleware.go index 002906a..f7e947f 100644 --- a/internal/entrypoint/middleware.go +++ b/internal/entrypoint/middleware.go @@ -18,7 +18,7 @@ func (e *Entrypoint) authenticateMiddleware(next http.HandlerFunc) http.HandlerF Str("from", r.RemoteAddr). Str("uri", r.URL.RequestURI()). Msg("authentication failed") - http.Error(w, "Unauthorized", http.StatusUnauthorized) + http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) return } ctx := context.WithValue(r.Context(), clientContextKey, client) @@ -33,7 +33,7 @@ func (e *Entrypoint) isAllowedMiddleware(next http.HandlerFunc) http.HandlerFunc Str("from", r.RemoteAddr). Str("uri", r.URL.RequestURI()). Msg("request not allowed") - http.Error(w, err.Error(), http.StatusForbidden) + http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) return } next.ServeHTTP(w, r)