Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mazzz1y committed Nov 25, 2024
1 parent ebe25c3 commit 9c9b4c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/keenetic-auth-gw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions internal/entrypoint/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9c9b4c6

Please sign in to comment.