diff options
author | 2023-02-17 12:02:29 +0100 | |
---|---|---|
committer | 2023-02-17 12:02:29 +0100 | |
commit | 68e6d08c768b789987a753d42f66caf73ce10ee1 (patch) | |
tree | 1c9eb6da6c326266d653de80684c3aec58922638 /internal/oidc/handlecallback.go | |
parent | [bugfix] Set 'discoverable' properly on API accounts (#1511) (diff) | |
download | gotosocial-68e6d08c768b789987a753d42f66caf73ce10ee1.tar.xz |
[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 <grufwub@gmail.com>
Diffstat (limited to 'internal/oidc/handlecallback.go')
-rw-r--r-- | internal/oidc/handlecallback.go | 10 |
1 files changed, 5 insertions, 5 deletions
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) |