Skip to content

add: logging for SAML IdP initiated auth#137

Merged
jono-booth merged 1 commit intorelease-ulmofrom
jb/saml-auth-redirect
Feb 18, 2026
Merged

add: logging for SAML IdP initiated auth#137
jono-booth merged 1 commit intorelease-ulmofrom
jb/saml-auth-redirect

Conversation

@jono-booth
Copy link
Copy Markdown

Logging to debug SAML initiated login requests

Copilot AI review requested due to automatic review settings February 18, 2026 14:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive logging to debug SAML Identity Provider (IdP) initiated authentication flows in the third-party authentication pipeline. The logging statements capture key decision points and state information during the authentication process to help diagnose issues with SAML IdP-initiated login requests.

Changes:

  • Added logging to capture provider information, authentication state, and user existence checks
  • Extracted function call results into temporary variables to enable logging without changing logic
  • Added logging at critical control flow decision points (user exists, force account creation, dispatch routing)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +620 to +632
logger.info(
'[THIRD_PARTY_AUTH] ensure_user_information: auth_entry=%s backend=%s is_provider_saml=%s '
'current_provider=%s skip_email_verification=%s send_to_registration_first=%s '
'email=%s kwargs_response_keys=%s',
auth_entry,
current_partial.backend,
_is_saml,
_provider_obj.provider_id if _provider_obj else None,
_provider_obj.skip_email_verification if _provider_obj else None,
_provider_obj.send_to_registration_first if _provider_obj else None,
details.get('email') if details else None,
list((kwargs.get('response') or {}).keys()),
)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging email addresses exposes Personally Identifiable Information (PII) in application logs. This creates potential privacy and compliance risks (GDPR, CCPA, etc.) as logs may be retained longer than necessary, shared with third parties, or stored insecurely. While this pattern exists elsewhere in the codebase (e.g., lines 854, 872, 885), consider whether the email is essential for debugging SAML IdP initiated auth. If debugging requires identifying users, consider logging a hashed version of the email or just the domain (e.g., @example.com) instead of the full email address. If the full email is necessary, ensure your logging infrastructure has appropriate PII protection controls in place.

Copilot uses AI. Check for mistakes.
Comment on lines +638 to +642
logger.info(
'[THIRD_PARTY_AUTH] ensure_user_information: user_exists=%s user_details_email=%s',
_user_exists,
(user_details or {}).get('email'),
)
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log statement also logs email addresses which exposes PII. The same privacy and compliance concerns apply here as in the previous logging statement. Consider whether the email is essential for debugging or if alternative identifiers could be used.

Copilot uses AI. Check for mistakes.
Comment on lines +618 to +619
_is_saml = is_provider_saml()
_provider_obj = provider.Registry.get_from_pipeline({'backend': current_partial.backend, 'kwargs': kwargs})
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provider object is being fetched multiple times via provider.Registry.get_from_pipeline(). It's called once here (line 619), once inside is_provider_saml() (line 618, which internally calls it at line 607), and again inside should_force_account_creation() (line 654, which internally calls it at line 601). Consider refactoring to fetch the provider object once and pass it to these helper functions, or refactor the helper functions to accept an optional provider parameter. This would reduce redundant lookups and improve performance.

Copilot uses AI. Check for mistakes.
@jono-booth jono-booth merged commit 5b9aa5a into release-ulmo Feb 18, 2026
108 of 109 checks passed
@jono-booth jono-booth deleted the jb/saml-auth-redirect branch February 18, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants