diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-24 13:29:53 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-24 13:29:53 +0300 |
commit | 5ffd39e41866614de47ff427d3156062a6879e1c (patch) | |
tree | 7c4b031596057329ca5dc3b7a406d2b631a11c7d /internal/auth | |
parent | bc61f03703dffb79c3d9d887385b968315362caa (diff) |
Respond with 502 if a domain can not be retrieved from a source
Diffstat (limited to 'internal/auth')
-rw-r--r-- | internal/auth/auth.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 320dcb11..d84fc690 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -198,14 +198,17 @@ func (a *Auth) checkAuthenticationResponse(session *sessions.Session, w http.Res http.Redirect(w, r, redirectURI, 302) } -func (a *Auth) domainAllowed(domain string, domains *source.Domains) bool { - domainConfigured := (domain == a.pagesDomain) || strings.HasSuffix("."+domain, a.pagesDomain) +func (a *Auth) domainAllowed(name string, domains *source.Domains) bool { + isConfigured := (name == a.pagesDomain) || strings.HasSuffix("."+name, a.pagesDomain) - if domainConfigured { + if isConfigured { return true } - return domains.HasDomain(domain) + domain, err := domains.GetDomain(name) + + // domain exists and there is no error + return (domain != nil && err == nil) } func (a *Auth) handleProxyingAuth(session *sessions.Session, w http.ResponseWriter, r *http.Request, domains *source.Domains) bool { |