When using Discourse as a DiscourseConnect Provider (SSO Provider), the user’s email address is exposed in the 302 redirect URL to the relying party. This happens because the populate_user_data method in lib/second_factor/actions/discourse_connect_provider.rb always sets the email:
This email is thenBase64-encoded and included in the redirect URL: https://target-site.com/callback?sso=<base64_payload>&sig=<hmac_signature>
Decoding the base64 payload reveals the email address in plain text.
Impact
Browser history: Email is recorded in browser history
Nginx logs: The full URL is logged in nginx access logs
Target site logs: The relying party receives the email without explicit user consent
User expectation: Users typically authorize to prove “I am a legitimate user” - they don’t expect their email to be shared
Expected behavior
Users should be able to control whether their email is shared with the relying party. There should be a configuration option similar to discourse_connect_overrides_groups, discourse_connect_overrides_avatar, etc.
Currently there is no site setting to disable this behavior. Writing a plugin to override this behavior is possible but not ideal.
Add a site setting like discourse_connect_provider_includes_email (default: true for backward compatibility) to control whether email is included in the response
Or implement POST-based callback instead of GET 302 redirect to avoid URL logging
The HMAC signature only ensures the payload hasn’t been tampered with - it doesn’t encrypt the data. Base64 is encoding, not encryption, so anyone can decode it to read the contents.
The core issue is: we don’t want to expose unnecessary user information (like email) to “third-party sites using Discourse for SSO login”. Users authorize only to prove “I am a legitimate user” - they don’t expect their email to be shared.
Would a site setting to control whether email is returned be acceptable?
To give you some context on the use case: our forum is a “campus forum,” and a student built a free website for other students to use. They want to use our Discourse-based campus forum to authenticate whether a user is indeed a student at our school - essentially proving “I am a legitimate student here.”
In this scenario, the external website only needs to know “this is a valid user from our campus forum” - they don’t necessarily need the user’s email, which is sensitive information that shouldn’t be shared unnecessarily.
I’ll work on a PR that adds a site setting to control this behavior, with a default that maintains backward compatibility for existing installations.