diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-05-28 11:07:03 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-07-06 02:13:51 +0300 |
commit | 4f82a5659cfcec5e7782b80f0d551353cbdcc1dc (patch) | |
tree | 0b9ccdfa09a1cbf932dfd23d26506b3096ccd285 /internal/domain/domain.go | |
parent | fb2c26ff998b809baddeb9618aae52c49200bc8b (diff) |
Get namespace domain if auth fails for a private domain
Add acceptance test and some more domains for testing
Move namespace domain serving logic
Restore go.sum
Remove redundant return
Fix linter
Diffstat (limited to 'internal/domain/domain.go')
-rw-r--r-- | internal/domain/domain.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 17a0e1d3..2a301121 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -168,3 +168,24 @@ func (d *Domain) ServeNotFoundHTTP(w http.ResponseWriter, r *http.Request) { request.ServeNotFoundHTTP(w, r) } + +// ServeNamespaceNotFound will try to find a parent namespace domain for a request +// that failed authentication so that we serve the custom namespace error page for +// public namespace domains +func (d *Domain) ServeNamespaceNotFound(w http.ResponseWriter, r *http.Request) { + // override the path nd try to resolve the domain name + r.URL.Path = "/" + namespaceDomain, err := d.Resolver.Resolve(r) + if err != nil { + httperrors.Serve404(w) + return + } + + // for namespace domains that have no access control enabled + if namespaceDomain.LookupPath.IsNamespaceProject && !namespaceDomain.LookupPath.HasAccessControl { + namespaceDomain.ServeNotFoundHTTP(w, r) + return + } + + httperrors.Serve404(w) +} |