Automatic addition of users to group based on email domain

AI-generated summary

The discussion revolves around an issue with automatic user group assignment based on email domain in a Discourse forum using SSO. hollyw reports that new users with a specific email domain are not being automatically added to a custom group, requiring manual intervention to update membership. codinghorror notes this is a known inconsistency, and sam identifies it as an SSO bug, particularly when sso_overrides_email is enabled. sam explains that the auto-group membership rule doesn’t apply retroactively to users updated via SSO, only to initial creations, and suggests ensuring the “Apply the same email domain rule to add existing registered users” option is enabled, though this setting may be removed in the future. pfaffman recommends managing group assignments via SSO during login instead.

On our forum, we created a custom group for users with a certain email domain. My understanding was that new users who join the site with this domain would automatically be added to the group. However, it doesn’t seem to be functioning in an automated fashion. Right now I have to go to Group > Membership and click Save Changes to see the most recent wave of new users get added to this group. Otherwise they don’t seem to be added.

Is this expected behavior? I should also add that we’re using SSO, so I’m unsure whether that would impact this feature.

@sam this is the same as the other recent report, where these rules aren’t consistent.

Looks like an SSO bug to me

Can you confirm you are using Setup DiscourseConnect - Official Single-Sign-On for Discourse (sso)

Yes, we are using the official SSO for Discourse.

I think this is the bug.

When you were updating emails via SSO cause you have sso_overrides_email enabled the auto group membership was not taking.

It would take for initial user creations.

Note, there is the whole “retroactive” concept that is massively confusing, we should probably just remove that. I recommend you make sure Apply the same email domain rule to add existing registered users is always set, we are going to be removing it.

https://github.com/discourse/discourse/commit/b824898f614d21c43a78fec30481757341106d5a

I would suggest that you manage those groups with sso and push them when they log in.