Discourse/Drupal SSO Username Questions

AI-generated summary

mb5789 reports that their Discourse instance now assigns generic usernames like “user####” instead of deriving them from email addresses (e.g., “tonysmith1” from “tonysmith1@aol.com”). They also ask if Drupal profile data (title, business name, etc.) can be synced to Discourse. simon explains that this username change was intentional to avoid exposing email addresses — if no username is provided in the SSO payload, Discourse defaults to “user” plus a number. The fix is to explicitly supply a username in the SSO payload; for email-based usernames, split the email at “@” and send the local part. Regarding profile data, simon confirms that DiscourseConnect supports syncing fields like title and bio via the SSO payload, pointing to the single_sign_on.rb file for the full list of accessible parameters under ACCESSORS and BOOLS.

Hey all,

Looks like our instance of Discourse is now bringing everyone’s username over as some sort of variant on “user####” where it previously brought them over as some variant on their email address (ie if their username was “tonysmith1@aol.com” it would make their username “tonysmith1”). Is there any way to change this?

Also, is there a way to bring over profile information from a user in Drupal to fill out a user’s profile in Discourse? ie title, business name, etc

This is the result of a recent change. Previously, if a username was not supplied in the SSO payload, a username would be created based on the user’s email address. The risk in doing this is that it potentially exposes user’s email addresses. If no username is supplied in the SSO payload, Discourse now sets the username to “user” with a number appended so that usernames are unique.

The solution to this is to supply a username in the SSO payload. If you really want to create usernames based on user’s email addresses, you should split the email address at the @ character and send the name part of the address as the username.

I believe you are using DiscourseConnect for SSO. This allows you to set quite a few parameters in the SSO payload. Have a look at the ACCESSORS and BOOLS lists at the top of this file to see which parameters can be set through the DiscourseConnect payload: https://github.com/discourse/discourse/blob/main/lib/single_sign_on.rb. You will see that both bio and title can be set in this way.