diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2019-06-03 14:22:03 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-03 14:22:03 +0300 |
commit | 9df35356572e09dc2c0907113bf64479204e46a9 (patch) | |
tree | 70297534cace3ad4c6015df32757690cc9244992 /app.go | |
parent | 80fa0bb4e200a6b3b9194766dd209de28d1cf08a (diff) |
Redirect unknown ACME challenges to the GitLab instance
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -17,6 +17,7 @@ import ( log "github.com/sirupsen/logrus" mimedb "gitlab.com/lupine/go-mimedb" + "gitlab.com/gitlab-org/gitlab-pages/internal/acme" "gitlab.com/gitlab-org/gitlab-pages/internal/admin" "gitlab.com/gitlab-org/gitlab-pages/internal/artifact" "gitlab.com/gitlab-org/gitlab-pages/internal/auth" @@ -38,10 +39,11 @@ var ( type theApp struct { appConfig - dm domain.Map - lock sync.RWMutex - Artifact *artifact.Artifact - Auth *auth.Auth + dm domain.Map + lock sync.RWMutex + Artifact *artifact.Artifact + Auth *auth.Auth + AcmeMiddleware *acme.Middleware } func (a *theApp) isReady() bool { @@ -166,6 +168,10 @@ func (a *theApp) serveContent(ww http.ResponseWriter, r *http.Request, https boo host, domain := a.getHostAndDomain(r) + if a.AcmeMiddleware.ServeAcmeChallenges(&w, r, domain) { + return + } + if a.Auth.TryAuthenticate(&w, r, a.dm, &a.lock) { return } @@ -360,6 +366,10 @@ func runApp(config appConfig) { config.RedirectURI, config.GitLabServer) } + if config.GitLabServer != "" { + a.AcmeMiddleware = &acme.Middleware{GitlabURL: config.GitLabServer} + } + configureLogging(config.LogFormat, config.LogVerbose) if err := mimedb.LoadTypes(); err != nil { |