# שכתוב שם משתמש עם כניסות SAML/OpenIDC

**URL:** https://meta.discourse.org/t/rewrite-username-with-saml-openidc-logins/220999
**Category:** Self-hosting
**Tags:** hosting
**Created:** [15 במרץ,‏ 2022,‏ 1:41pm UTC](https://meta.discourse.org/t/rewrite-username-with-saml-openidc-logins/220999 "2022-03-15T13:41:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![holtgrewe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/holtgrewe/32/253122_2.png) [@holtgrewe](https://meta.discourse.org/u/holtgrewe)
#### Post date: [15 במרץ,‏ 2022,‏ 1:41pm UTC](https://meta.discourse.org/t/rewrite-username-with-saml-openidc-logins/220999/1 "2022-03-15T13:41:50Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [15 במרץ,‏ 2022,‏ 2:59pm UTC](https://meta.discourse.org/t/rewrite-username-with-saml-openidc-logins/220999/2 "2022-03-15T14:59:04Z")

</div>

> [@holtgrewe](#):
>
> modifying the source code of the connectors but the mapping probably needs to be done in a lot of places

I think the required modifications would be limited to a [single function](https://github.com/discourse/discourse-saml/blob/88054bdad07940147bdfb9d33005549be5be0a07/lib/saml_authenticator.rb#L360-L374).

---

<div class="post-metadata">

### Author: ![holtgrewe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/holtgrewe/32/253122_2.png) [@holtgrewe](https://meta.discourse.org/u/holtgrewe)
#### Post date: [15 במרץ,‏ 2022,‏ 4:16pm UTC](https://meta.discourse.org/t/rewrite-username-with-saml-openidc-logins/220999/3 "2022-03-15T16:16:16Z")

</div>

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