@@ -70,28 +70,30 @@ func proxyHandler(logger logr.Logger, proxies map[string]*httputil.ReverseProxy,
7070 return
7171 }
7272
73+ handlerLogger := logger .WithValues ("path" , r .URL .Path )
74+
7375 // Check basic auth with local auth configuration
7476 err = authz .IsPermitted (r .URL .EscapedPath (), token )
7577 if err != nil {
76- logger .Error (err , "Received unauthorized request" )
78+ handlerLogger .Error (err , "Received unauthorized request" )
7779 http .Error (w , "User not permitted" , http .StatusForbidden )
7880 return
7981 }
8082 pat , err := authz .GetPatForToken (token )
8183 if err != nil {
82- logger .Error (err , "Could not find the PAT for the given token" )
84+ handlerLogger .Error (err , "Could not find the PAT for the given token" )
8385 http .Error (w , "Internal server error" , http .StatusInternalServerError )
8486 return
8587 }
8688 target , err := authz .GetTargetForToken (token )
8789 if err != nil {
88- logger .Error (err , "Target could not be created from the token" )
90+ handlerLogger .Error (err , "Target could not be created from the token" )
8991 http .Error (w , "Internal server error" , http .StatusInternalServerError )
9092 return
9193 }
9294
9395 // Overwrite the authorization header with the PAT token
94- logger .Info ("Authenticated request" , "path" , r . URL . Path )
96+ handlerLogger .Info ("Authenticated request" )
9597 r .Host = target .Host
9698 r .Header .Del ("Authorization" )
9799 patB64 := base64 .StdEncoding .EncodeToString ([]byte (fmt .Sprintf ("pat:%s" , pat )))
@@ -100,7 +102,7 @@ func proxyHandler(logger logr.Logger, proxies map[string]*httputil.ReverseProxy,
100102 // Forward the request to the correct proxy
101103 proxy , ok := proxies [target .String ()]
102104 if ! ok {
103- logger .Info ("missing proxy for target" )
105+ handlerLogger .Info ("missing proxy for target" )
104106 http .Error (w , "Internal server error" , http .StatusInternalServerError )
105107 return
106108 }
0 commit comments