From e9bbecfacecbccc08f359f2f2ee3f13d5e4e0c70 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 5 Aug 2017 12:48:36 -0400 Subject: [PATCH 1/2] options: gracefully report un-parsed upstream URL upstreamURL is a nil pointer if there is an error parsing --upstream --- options.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/options.go b/options.go index f1df916..e6c6c4e 100644 --- a/options.go +++ b/options.go @@ -142,14 +142,13 @@ func (o *Options) Validate() error { for _, u := range o.Upstreams { upstreamURL, err := url.Parse(u) if err != nil { - msgs = append(msgs, fmt.Sprintf( - "error parsing upstream=%q %s", - upstreamURL, err)) + msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err)) + } else { + if upstreamURL.Path == "" { + upstreamURL.Path = "/" + } + o.proxyURLs = append(o.proxyURLs, upstreamURL) } - if upstreamURL.Path == "" { - upstreamURL.Path = "/" - } - o.proxyURLs = append(o.proxyURLs, upstreamURL) } for _, u := range o.SkipAuthRegex { From 3d8b59ef716756370df2903266d81e80c7e708a3 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 5 Aug 2017 12:54:31 -0400 Subject: [PATCH 2/2] options: wrap missing-email-validation error message --- options.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/options.go b/options.go index e6c6c4e..ac0a806 100644 --- a/options.go +++ b/options.go @@ -134,7 +134,8 @@ func (o *Options) Validate() error { msgs = append(msgs, "missing setting: client-secret") } if o.AuthenticatedEmailsFile == "" && len(o.EmailDomains) == 0 && o.HtpasswdFile == "" { - msgs = append(msgs, "missing setting for email validation: email-domain or authenticated-emails-file required.\n use email-domain=* to authorize all email addresses") + msgs = append(msgs, "missing setting for email validation: email-domain or authenticated-emails-file required."+ + "\n use email-domain=* to authorize all email addresses") } o.redirectURL, msgs = parseURL(o.RedirectURL, "redirect", msgs)