From 68e6d08c768b789987a753d42f66caf73ce10ee1 Mon Sep 17 00:00:00 2001 From: Daenney Date: Fri, 17 Feb 2023 12:02:29 +0100 Subject: [feature] Add a request ID and include it in logs (#1476) This adds a lightweight form of tracing to GTS. Each incoming request is assigned a Request ID which we then pass on and log in all our log lines. Any function that gets called downstream from an HTTP handler should now emit a requestID=value pair whenever it logs something. Co-authored-by: kim --- internal/oidc/handlecallback.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/oidc') diff --git a/internal/oidc/handlecallback.go b/internal/oidc/handlecallback.go index 770789362..8fa7dbbac 100644 --- a/internal/oidc/handlecallback.go +++ b/internal/oidc/handlecallback.go @@ -33,23 +33,23 @@ func (i *idp) HandleCallback(ctx context.Context, code string) (*Claims, gtserro return nil, gtserror.NewErrorBadRequest(err, err.Error()) } - log.Debug("exchanging code for oauth2token") + log.Debug(ctx, "exchanging code for oauth2token") oauth2Token, err := i.oauth2Config.Exchange(ctx, code) if err != nil { err := fmt.Errorf("error exchanging code for oauth2token: %s", err) return nil, gtserror.NewErrorInternalError(err) } - log.Debug("extracting id_token") + log.Debug(ctx, "extracting id_token") rawIDToken, ok := oauth2Token.Extra("id_token").(string) if !ok { err := errors.New("no id_token in oauth2token") return nil, gtserror.NewErrorBadRequest(err, err.Error()) } - log.Debugf("raw id token: %s", rawIDToken) + log.Debugf(ctx, "raw id token: %s", rawIDToken) // Parse and verify ID Token payload. - log.Debug("verifying id_token") + log.Debug(ctx, "verifying id_token") idTokenVerifier := i.provider.Verifier(i.oidcConf) idToken, err := idTokenVerifier.Verify(ctx, rawIDToken) if err != nil { @@ -57,7 +57,7 @@ func (i *idp) HandleCallback(ctx context.Context, code string) (*Claims, gtserro return nil, gtserror.NewErrorUnauthorized(err, err.Error()) } - log.Debug("extracting claims from id_token") + log.Debug(ctx, "extracting claims from id_token") claims := &Claims{} if err := idToken.Claims(claims); err != nil { err := fmt.Errorf("could not parse claims from idToken: %s", err) -- cgit v1.2.3