Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-07-07 05:19:48 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-07-07 05:19:48 +0300
commit86afc1dfeeb07fbc140d08ef8cdcfd8cbd4d7bcb (patch)
tree41a2d15d113a8dba2513ca42d9c82722d1c5892b /internal/auth/auth.go
parente74c91bfe5c95d6da82691e0c753cc50b661613c (diff)
Improve logging and correlation ID
Diffstat (limited to 'internal/auth/auth.go')
-rw-r--r--internal/auth/auth.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index 5d503799..aab2f3cd 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -15,14 +15,14 @@ import (
"github.com/gorilla/securecookie"
"github.com/gorilla/sessions"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"golang.org/x/crypto/hkdf"
- "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/labkit/errortracking"
"gitlab.com/gitlab-org/gitlab-pages/internal/httperrors"
"gitlab.com/gitlab-org/gitlab-pages/internal/httptransport"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/logging"
"gitlab.com/gitlab-org/gitlab-pages/internal/request"
"gitlab.com/gitlab-org/gitlab-pages/internal/source"
)
@@ -270,7 +270,7 @@ func (a *Auth) handleProxyingAuth(session *sessions.Session, w http.ResponseWrit
url := fmt.Sprintf(authorizeURLTemplate, a.gitLabServer, a.clientID, a.redirectURI, state, a.authScope)
- logRequest(r).WithFields(log.Fields{
+ logRequest(r).WithFields(logrus.Fields{
"gitlab_server": a.gitLabServer,
"pages_domain": domain,
}).Info("Redirecting user to gitlab for oauth")
@@ -615,14 +615,8 @@ func checkResponseForInvalidToken(resp *http.Response, session *sessions.Session
return false
}
-func logRequest(r *http.Request) *log.Entry {
- state := r.URL.Query().Get("state")
- return log.WithFields(log.Fields{
- "correlation_id": correlation.ExtractFromContext(r.Context()),
- "host": r.Host,
- "path": r.URL.Path,
- "state": state,
- })
+func logRequest(r *http.Request) *logrus.Entry {
+ return logging.LogRequest(r).WithField("state", r.URL.Query().Get("state"))
}
// generateKeys derives count hkdf keys from a secret, ensuring the key is