Merge pull request #431 from ploxiln/nil_upstream_url

gracefully report un-parsed upstream URL
This commit is contained in:
Jehiah Czebotar 2017-08-28 20:46:30 -04:00 committed by GitHub
commit 23cef89236

View File

@ -131,7 +131,8 @@ func (o *Options) Validate() error {
msgs = append(msgs, "missing setting: client-secret") msgs = append(msgs, "missing setting: client-secret")
} }
if o.AuthenticatedEmailsFile == "" && len(o.EmailDomains) == 0 && o.HtpasswdFile == "" { 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) o.redirectURL, msgs = parseURL(o.RedirectURL, "redirect", msgs)
@ -139,15 +140,14 @@ func (o *Options) Validate() error {
for _, u := range o.Upstreams { for _, u := range o.Upstreams {
upstreamURL, err := url.Parse(u) upstreamURL, err := url.Parse(u)
if err != nil { if err != nil {
msgs = append(msgs, fmt.Sprintf( msgs = append(msgs, fmt.Sprintf("error parsing upstream: %s", err))
"error parsing upstream=%q %s", } else {
upstreamURL, err))
}
if upstreamURL.Path == "" { if upstreamURL.Path == "" {
upstreamURL.Path = "/" upstreamURL.Path = "/"
} }
o.proxyURLs = append(o.proxyURLs, upstreamURL) o.proxyURLs = append(o.proxyURLs, upstreamURL)
} }
}
for _, u := range o.SkipAuthRegex { for _, u := range o.SkipAuthRegex {
CompiledRegex, err := regexp.Compile(u) CompiledRegex, err := regexp.Compile(u)