From 06aeccc03e3626c10c6a0c87e917d21125d6e8a8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 27 Sep 2019 12:03:29 +0200 Subject: Remove the concept of a custom domain from domain package --- internal/domain/domain.go | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'internal/domain/domain.go') diff --git a/internal/domain/domain.go b/internal/domain/domain.go index 321c0cd9..d57687a9 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -16,7 +16,6 @@ type Domain struct { Location string CertificateCert string CertificateKey string - Customized bool // TODO we should get rid of this Resolver Resolver @@ -33,14 +32,6 @@ func (d *Domain) String() string { return d.Name } -func (d *Domain) isCustomDomain() bool { - if d.isUnconfigured() { - panic("project config and group config should not be nil at the same time") - } - - return d.Customized -} - func (d *Domain) isUnconfigured() bool { if d == nil { return true @@ -62,6 +53,7 @@ func (d *Domain) resolve(r *http.Request) (*Project, string) { return project, subpath } +// GetProject returns a project details based on the request func (d *Domain) GetProject(r *http.Request) *Project { project, _ := d.resolve(r) @@ -117,7 +109,8 @@ func (d *Domain) IsAccessControlEnabled(r *http.Request) bool { // HasAcmeChallenge checks domain directory contains particular acme challenge func (d *Domain) HasAcmeChallenge(r *http.Request, token string) bool { - if d.isUnconfigured() || !d.isCustomDomain() || !d.HasProject(r) { + // TODO is that safe to redirect to acme challenge in GitLab if it is a grup domain/ + if d.isUnconfigured() || !d.HasProject(r) { return false } @@ -130,12 +123,6 @@ func (d *Domain) IsNamespaceProject(r *http.Request) bool { return false } - // If request is to a custom domain, we do not handle it as a namespace project - // as there can't be multiple projects under the same custom domain - if d.isCustomDomain() { // TODO do we need a separate path for this - return false - } - if project := d.GetProject(r); project != nil { return project.IsNamespaceProject } @@ -167,8 +154,7 @@ func (d *Domain) HasProject(r *http.Request) bool { // EnsureCertificate parses the PEM-encoded certificate for the domain func (d *Domain) EnsureCertificate() (*tls.Certificate, error) { - // TODO check len certificates instead of custom domain! - if d.isUnconfigured() || !d.isCustomDomain() { + if d.isUnconfigured() || len(d.CertificateKey) == 0 || len(d.CertificateCert) == 0 { return nil, errors.New("tls certificates can be loaded only for pages with configuration") } -- cgit v1.2.3