-
Notifications
You must be signed in to change notification settings - Fork 670
chore(oidc): show extra_data in debug mode #3769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,9 +91,7 @@ def pre_social_login(self, request, sociallogin): | |
| extra = sociallogin.account.extra_data | ||
| logger.debug( | ||
| "pre_social_login: extra_data received", | ||
| extra_data_keys=list(extra.keys()), | ||
| has_userinfo="userinfo" in extra, | ||
| has_id_token="id_token" in extra, | ||
| extra_data=extra, | ||
| provider=sociallogin.account.provider, | ||
| ) | ||
| # Primary lookup (legacy format) | ||
|
|
@@ -135,23 +133,37 @@ def pre_social_login(self, request, sociallogin): | |
| return Response( | ||
| {"message": "Email not provided."}, status=HTTP_401_UNAUTHORIZED | ||
| ) | ||
| logger.info( | ||
| "pre_social_login: resolved email for user lookup", | ||
| email_domain=email_address.split("@")[-1] | ||
| if "@" in email_address | ||
| else "unknown", | ||
| logger.debug( | ||
| "pre_social_login: resolved email from IdP", | ||
| idp_email=email_address, | ||
| idp_email_repr=repr(email_address), | ||
| provider=sociallogin.account.provider, | ||
| ) | ||
| try: | ||
| user = User.objects.get(email__iexact=email_address) | ||
| logger.debug( | ||
| "pre_social_login: user matched", | ||
| idp_email=email_address, | ||
| db_email=user.email, | ||
| user_id=str(user.id), | ||
| is_active=user.is_active, | ||
| ) | ||
|
Comment on lines
+136
to
+150
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove raw email values from these lookup traces.
🛡️ Suggested change+ normalized_email = email_address.strip()
+ email_domain = (
+ normalized_email.partition("@")[2].lower() if "@" in normalized_email else None
+ )
logger.debug(
"pre_social_login: resolved email from IdP",
- idp_email=email_address,
- idp_email_repr=repr(email_address),
provider=sociallogin.account.provider,
+ email_domain=email_domain,
+ had_surrounding_whitespace=normalized_email != email_address,
+ had_uppercase=normalized_email != normalized_email.casefold(),
)
@@
logger.debug(
"pre_social_login: user matched",
- idp_email=email_address,
- db_email=user.email,
user_id=str(user.id),
is_active=user.is_active,
+ email_domain=email_domain,
)
@@
logger.debug(
"pre_social_login: user not found - check DB for this email",
- idp_email=email_address,
- idp_email_repr=repr(email_address),
provider=sociallogin.account.provider,
+ email_domain=email_domain,
+ had_surrounding_whitespace=normalized_email != email_address,
+ had_uppercase=normalized_email != normalized_email.casefold(),
)Also applies to: 163-167 🤖 Prompt for AI Agents |
||
| sociallogin.user = user | ||
| sociallogin.connect(request, user) | ||
| logger.info( | ||
| "pre_social_login: social account connected", | ||
| provider=sociallogin.account.provider, | ||
| user_id=str(user.id), | ||
| ) | ||
| except User.DoesNotExist: | ||
| logger.error( | ||
| "pre_social_login: user not found", | ||
| email_domain=email_address.split("@")[-1] | ||
| if "@" in email_address | ||
| else "unknown", | ||
| provider=sociallogin.account.provider, | ||
| ) | ||
| logger.debug( | ||
| "pre_social_login: user not found - check DB for this email", | ||
| idp_email=email_address, | ||
| idp_email_repr=repr(email_address), | ||
| provider=sociallogin.account.provider, | ||
| ) | ||
| return Response( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not dump the full IdP payload to logs.
extra_data=extrawill persist the full provider response whenever debug logging is enabled. This project has no log-redaction layer, and the failure path just below already shows the safer pattern by logging keys only.🛡️ Suggested change
logger.debug( "pre_social_login: extra_data received", - extra_data=extra, provider=sociallogin.account.provider, + extra_data_keys=list(extra.keys()), + userinfo_keys=list(extra.get("userinfo", {}).keys()), + id_token_keys=list(extra.get("id_token", {}).keys()), )📝 Committable suggestion
🤖 Prompt for AI Agents