mirror of https://github.com/k3s-io/k3s
Merge pull request #39226 from luksa/kubectl_proxy_empty_path
Automatic merge from submit-queue (batch tested with PRs 39311, 39226, 39445) Make kubectl proxy accept empty path **What this PR does / why we need it**: The kubectl 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 ""). After someone runs kubectl proxy and tries accessing it with curl, they will probably just try hitting localhost:8001 (which returns an "Unauthorized" response) instead of say localhost:8001/api (which returns a proper response from the API server). Also, whoever previously modified the DefaultPathAcceptRE regex was obviously expecting the regex to accept requests for localhost:8001/ ```release-note fix issue with kubectl proxy so that it will proxy an empty path - e.g. http://localhost:8001 ```pull/6/head
commit
51e6c879e7
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultHostAcceptRE = "^localhost$,^127\\.0\\.0\\.1$,^\\[::1\\]$"
|
DefaultHostAcceptRE = "^localhost$,^127\\.0\\.0\\.1$,^\\[::1\\]$"
|
||||||
DefaultPathAcceptRE = "^/.*"
|
DefaultPathAcceptRE = "^.*"
|
||||||
DefaultPathRejectRE = "^/api/.*/pods/.*/exec,^/api/.*/pods/.*/attach"
|
DefaultPathRejectRE = "^/api/.*/pods/.*/exec,^/api/.*/pods/.*/attach"
|
||||||
DefaultMethodRejectRE = "POST,PUT,PATCH"
|
DefaultMethodRejectRE = "POST,PUT,PATCH"
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,6 +40,15 @@ func TestAccept(t *testing.T) {
|
||||||
expectAccept bool
|
expectAccept bool
|
||||||
}{
|
}{
|
||||||
|
|
||||||
|
{
|
||||||
|
acceptPaths: DefaultPathAcceptRE,
|
||||||
|
rejectPaths: DefaultPathRejectRE,
|
||||||
|
acceptHosts: DefaultHostAcceptRE,
|
||||||
|
path: "",
|
||||||
|
host: "127.0.0.1",
|
||||||
|
method: "GET",
|
||||||
|
expectAccept: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
acceptPaths: DefaultPathAcceptRE,
|
acceptPaths: DefaultPathAcceptRE,
|
||||||
rejectPaths: DefaultPathRejectRE,
|
rejectPaths: DefaultPathRejectRE,
|
||||||
|
|
Loading…
Reference in New Issue