# Keycloak, Discourse and SAML again

**URL:** https://meta.discourse.org/t/keycloak-discourse-and-saml-again/165732
**Category:** SSO
**Created:** [September 29, 2020, 1:15pm UTC](https://meta.discourse.org/t/keycloak-discourse-and-saml-again/165732 "2020-09-29T13:15:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nahimov](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@nahimov](https://meta.discourse.org/u/nahimov)
#### Post date: [September 29, 2020, 1:15pm UTC](https://meta.discourse.org/t/keycloak-discourse-and-saml-again/165732/1 "2020-09-29T13:15:10Z")

</div>

I somehow configured Keycloak for SAML authorization with Discourse, even transparent user creation works.  
But now there is a problem with passing user fields.  
I configured the following field mapping in Keycloak SAML (found on the Internet):

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/8/78a2928295866f68989167ea148bc5e4f0ce801f.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/f/6/f610bddb1a8aa023452aa815886f440c43c853be.png)

When I log into Discourse, I create a new user through Keycloak. This is what a user looks like in Keycloak:

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/7/577736c11b369ff6bb550bd7a792e8054d2b4074.png)

After that, the created user is transferred to Discourse. This is how fields for which there is a mapping are transferred to Discourse:

```plaintext
.............................
<saml:AttributeStatement>
    <saml:Attribute FriendlyName="Email" Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
        <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">a.nakhimov@yandex.ru</saml:AttributeValue>
    </saml:Attribute>
    <saml:Attribute FriendlyName="Username" Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
        <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">v.pupkin</saml:AttributeValue>
    </saml:Attribute>
</saml:AttributeStatement>
........................

```

This is what the submitted user looks like in Discourse:

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/5/45502b6fa613d7e364ecbb43132f213c1d704d31.png)

Points 1, 3 and 4 are completely correct. But I don’t like point 2… In Keycloak, the user has a normal First and Last Name. Why is only the first letter of the First Name left in Discourse? Is there any way to fix this? Maybe I need to do some other mapping in SAML?

---

<div class="post-metadata">

### Author: ![Ivan.bacher](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan.bacher/32/139602_2.png) [@Ivan.bacher](https://meta.discourse.org/u/Ivan.bacher)
#### Post date: [October 19, 2022, 3:31pm UTC](https://meta.discourse.org/t/keycloak-discourse-and-saml-again/165732/2 "2022-10-19T15:31:04Z")

</div>

Did you manage to get it working?
