From 6e30ede51676b08ca42fa2483d04f98eb6a24a1e Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Mon, 24 Apr 2017 16:40:23 -0300 Subject: [PATCH] Add stripPort helper --- core/pkg/ingress/annotations/authreq/main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/pkg/ingress/annotations/authreq/main.go b/core/pkg/ingress/annotations/authreq/main.go index 8b156766e..016cc2624 100644 --- a/core/pkg/ingress/annotations/authreq/main.go +++ b/core/pkg/ingress/annotations/authreq/main.go @@ -131,10 +131,22 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) { return &External{ URL: str, - Host: ur.Hostname(), + Host: stripPort(ur.Host), SigninURL: signin, Method: m, SendBody: sb, ResponseHeaders: h, }, nil } + +// TODO: Remove after upgrade to Go 1.8 +func stripPort(hostport string) string { + colon := strings.IndexByte(hostport, ':') + if colon == -1 { + return hostport + } + if i := strings.IndexByte(hostport, ']'); i != -1 { + return strings.TrimPrefix(hostport[:i], "[") + } + return hostport[:colon] +}