From c0aa2767aafa31b732d2eca72ab8348264eefa20 Mon Sep 17 00:00:00 2001 From: Marko Luksa Date: Sun, 25 Dec 2016 18:28:02 +0100 Subject: [PATCH] Make kubectl proxy accept empty path The proxy previously returned 403 Forbidden: Unauthorized when receiving a request from e.g. "curl localhost:8001" or "curl localhost:8001/". The previous DefaultPathAcceptRE regex was wrong as it assumed the path in this case would be "/" (but it is actually ""). --- pkg/kubectl/proxy_server.go | 2 +- pkg/kubectl/proxy_server_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/kubectl/proxy_server.go b/pkg/kubectl/proxy_server.go index 4ef7c62bfdb..d7a8edacc3d 100644 --- a/pkg/kubectl/proxy_server.go +++ b/pkg/kubectl/proxy_server.go @@ -34,7 +34,7 @@ import ( const ( DefaultHostAcceptRE = "^localhost$,^127\\.0\\.0\\.1$,^\\[::1\\]$" - DefaultPathAcceptRE = "^/.*" + DefaultPathAcceptRE = "^.*" DefaultPathRejectRE = "^/api/.*/pods/.*/exec,^/api/.*/pods/.*/attach" DefaultMethodRejectRE = "POST,PUT,PATCH" ) diff --git a/pkg/kubectl/proxy_server_test.go b/pkg/kubectl/proxy_server_test.go index ae536b91a8c..3aad8c315d9 100644 --- a/pkg/kubectl/proxy_server_test.go +++ b/pkg/kubectl/proxy_server_test.go @@ -40,6 +40,15 @@ func TestAccept(t *testing.T) { expectAccept bool }{ + { + acceptPaths: DefaultPathAcceptRE, + rejectPaths: DefaultPathRejectRE, + acceptHosts: DefaultHostAcceptRE, + path: "", + host: "127.0.0.1", + method: "GET", + expectAccept: true, + }, { acceptPaths: DefaultPathAcceptRE, rejectPaths: DefaultPathRejectRE,