Commit b05bd0c5 authored by Satnam Singh's avatar Satnam Singh

Merge pull request #10105 from caesarxuchao/fix-9287

exclude the port number when checking a request in "kubectl proxy"
parents 1fc6ef2e 9449a61b
...@@ -18,6 +18,7 @@ package kubectl ...@@ -18,6 +18,7 @@ package kubectl
import ( import (
"fmt" "fmt"
"net"
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
...@@ -94,8 +95,10 @@ func (f *FilterServer) accept(method, path, host string) bool { ...@@ -94,8 +95,10 @@ func (f *FilterServer) accept(method, path, host string) bool {
} }
func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) { func (f *FilterServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if f.accept(req.Method, req.URL.Path, req.Host) { host, _, _ := net.SplitHostPort(req.Host)
if f.accept(req.Method, req.URL.Path, host) {
f.delegate.ServeHTTP(rw, req) f.delegate.ServeHTTP(rw, req)
return
} }
rw.WriteHeader(http.StatusForbidden) rw.WriteHeader(http.StatusForbidden)
rw.Write([]byte("<h3>Unauthorized</h3>")) rw.Write([]byte("<h3>Unauthorized</h3>"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment