The discussion revolves around finding users by their external ID in Discourse, specifically in the context of Single Sign-On (SSO). michael28 initially requests this feature, suggesting it would simplify linking profiles when usernames don’t map 1:1. michael28 later discovers that the external ID is stored in the SingleSignOnRecord and proposes adding an API endpoint to convert external ID to user ID.
sam mentions that this feature exists as a custom field and may add a general route to find users by custom field. depeters shares the endpoint users/by-external/:external_id. However, sascha seeks documentation for this feature and wants to find users by external email or username.
sascha explains their use case, where they integrate Discourse into multiple webapp instances with different external IDs but the same email address. They want to fetch notifications by looking up users by their external email address. jomaxro and jomaxro suggest seeking help in a dedicated SSO topic.
Finally, david provides a link to a relevant topic, indicating that finding users by their identity provider’s external ID has been possible for some time.
For those of us making use of SSO, being able to find a user by their external ID would be very helpful. It would make linking profiles etc. much more straightforward in cases where username requirements may not fully map 1:1.
From my current understanding, external_id isn’t currently stored in the User model, but is passed as part of the payload. Could this data also be saved to the user model directly?
Did some further digging - storing external_id is probably redundant as it’s stored in SingleSignOnRecord. Perhaps it would make more sense to add an API endpoint could be added to convert the external_id to user_id?
I’m not sure any formal documentation exists. What exactly are you looking to do? A specific example would make it much easier to provide you with the details (or link to a topic) that you need.
We may have a bit of an unusual scenario but we’d like to integrate Discourse into multiple separate instances of our webapp, so effectively we have lots of IdPs and only one single Discourse instance.
These users have different external_ids but the same email address. Discourse will look up users by external_id and if not found will look them up by the email address and update the external_id if found.
This effectively makes discourse merge our external users, which is very nice, making the email address the only unique identifier as the external_id in discourse changes. To fetch notifications we’d like to look up a user by the external email address as the external_id does not necessarily match any more.