Gebruikersnaam herschrijven met SAML/OpenIDC Logins

AI-generated summary

The discussion revolves around rewriting usernames when using SAML/OpenIDC logins with Discourse. holtgrewe explains that while they successfully integrated Discourse with Keycloak via OpenIDC, usernames are being formatted as domain1_user and domain2_user, which they want to transform into user_domain1 and user_domain2. They note that this functionality isn’t supported out-of-the-box in either SAML or OpenIDC connectors and that modifying the source code is complex. RGJ suggests the changes might be limited to a single function in the SAML authenticator, specifically this function, making the task simpler with SAML than OpenIDC. holtgrewe acknowledges the insight and notes that SAML appears to be a more viable path for this customization.

First of all, thank you for providing such great software as open source.

I have successfully setup discourse on our server with OpenIDC integration to our local keycloak server. However, keycloak delivers user names as domain1\user and domain2\user etc. Users turn up as domain1_user and domain2_user. I would like to transmogrify the user names, potentially based on regular expresions. I would like to have user names to be user_domain1 and user_domain2.

As far as I can see, this is not properly supported in either the SAML or the OpenIDC connector. I tried modifying the source code of the connectors but the mapping probably needs to be done in a lot of places and I did not succeed.

Has anyone succeeded with such a setup yet?

I looked into configuring this into Keycloak, but Keycloak does not allow regular expressions in client mappings or from upstream federation servers on login…

I think the required modifications would be limited to a single function.

Oh, neat! I was focusing on OpenIDC but with SAML it looks simpler.