Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore(idp): debug log for user claims (#4717)

Joe Chen5dbe000713a8
diff --git a/backend/plugin/idp/oauth2/oauth2.go b/backend/plugin/idp/oauth2/oauth2.go
index ba468edcd8..92852eae22 100644
--- a/backend/plugin/idp/oauth2/oauth2.go
+++ b/backend/plugin/idp/oauth2/oauth2.go
@@ -95,6 +95,7 @@ func (p *IdentityProvider) UserInfo(token string) (*storepb.IdentityProviderUser
log.Error("Failed to unmarshal response body", zap.String("token", token), zap.String("body", string(body)), zap.Error(err))
return nil, errors.Wrap(err, "failed to unmarshal response body")
}
+ log.Debug("User info", zap.Any("claims", claims))
userInfo := &storepb.IdentityProviderUserInfo{}
if v, ok := claims[p.config.FieldMapping.Identifier].(string); ok {
diff --git a/backend/plugin/idp/oidc/oidc.go b/backend/plugin/idp/oidc/oidc.go
index bad336f9ae..f5d89b6917 100644
--- a/backend/plugin/idp/oidc/oidc.go
+++ b/backend/plugin/idp/oidc/oidc.go
@@ -6,8 +6,10 @@ import (
"github.com/coreos/go-oidc"
"github.com/pkg/errors"
+ "go.uber.org/zap"
"golang.org/x/oauth2"
+ "github.com/bytebase/bytebase/backend/common/log"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
@@ -91,7 +93,7 @@ func (p *IdentityProvider) UserInfo(ctx context.Context, token *oauth2.Token, no
}
if idToken.Nonce != nonce {
- return nil, errors.Errorf("mismatched nonce")
+ return nil, errors.Errorf("mismatched nonce, want %q but got %q", nonce, idToken.Nonce)
}
rawUserInfo, err := p.provider.UserInfo(ctx, oauth2.StaticTokenSource(token))
@@ -104,6 +106,7 @@ func (p *IdentityProvider) UserInfo(ctx context.Context, token *oauth2.Token, no
if err != nil {
return nil, errors.Wrap(err, "unmarshal claims")
}
+ log.Debug("User info", zap.Any("claims", claims))
userInfo := &storepb.IdentityProviderUserInfo{}
if v, ok := claims[p.config.FieldMapping.Identifier].(string); ok {