# Full name mapping when using SAML

**URL:** https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143
**Category:** SSO
**Created:** [October 22, 2018, 7:14am UTC](https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143 "2018-10-22T07:14:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tegebe](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tegebe](https://meta.discourse.org/u/tegebe)
#### Post date: [October 22, 2018, 7:14am UTC](https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143/1 "2018-10-22T07:14:25Z")

</div>

Hi there,

does anyone know how to map the full name when using SAML as login method?  
My SAML response looks like this and I can map any other other attribute in my IdP if necessary:

```
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Destination="https://logon.xyz.de/auth/saml/callback" ID="idLwrewprewewGG1wewe0X4VZKDDby1Htv8I" InResponseTo="_ade6fd8b-0ce0-48d0-afff-b0ad3375d8e6" IssueInstant="2018-10-18T08:05:37Z" Version="2.0">
    <saml:Issuer>https://logon.xyz.de/nidp/saml2/metadata</saml:Issuer>
    <samlp:Status>
        <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
    </samlp:Status>
    <saml:Assertion ID="id9sd5jjrejb3ererIZCJkrYjoG9_PI0" IssueInstant="2018-10-18T08:05:37Z" Version="2.0">

        ...

    <saml:AttributeStatement>
        <saml:Attribute xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
            <saml:AttributeValue xsi:type="xs:string">USERID</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="last_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
            <saml:AttributeValue xsi:type="xs:string">Surname</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="first_name" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
            <saml:AttributeValue xsi:type="xs:string">Givenname</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute xmlns:xs="http://www.w3.org/2001/XMLSchema" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
            <saml:AttributeValue xsi:type="xs:string">mail@example.org</saml:AttributeValue>
        </saml:Attribute>
    </saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>

```

Regards,  
Thilo

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/siedlerchr/32/242748_2.png) [@Siedlerchr](https://meta.discourse.org/u/Siedlerchr)
#### Post date: [December 7, 2021, 9:36am UTC](https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143/2 "2021-12-07T09:36:34Z")

</div>

For anyone else searching for a solution:

We had the same problem and only found a solution when looking into the soure code:

> <https://github.com/discourse/discourse-saml/blob/d5001ba62a5d8fea64cf5835dd0431c63647c0a7/lib/saml_authenticator.rb#L131-L137>

`fullName` is ignored.  
You have to have a mapping to the fields `firstName` and `lastName` for discourse in your Identity provider (We used Keycloak)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [December 7, 2021, 11:26am UTC](https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143/3 "2021-12-07T11:26:57Z")

</div>

Thanks for taking the time to dig into the code! That looks like a bug to me - we check the `fullName`, then replace it with `firstName` `lastName`. Line 133 in that snippet is totally useless 🤔

I’ve been working on the SAML plugin this week anyway, so here’s a fix:

[https://github.com/discourse/discourse-saml/pull/42](https://github.com/discourse/discourse-saml/pull/42)

Once that’s merged, the `fullName` will be correctly prioritised

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/siedlerchr/32/242748_2.png) [@Siedlerchr](https://meta.discourse.org/u/Siedlerchr)
#### Post date: [December 7, 2021, 11:44am UTC](https://meta.discourse.org/t/full-name-mapping-when-using-saml/100143/4 "2021-12-07T11:44:54Z")

</div>

@david Thanks for the quick fix!

> That looks like a bug to me - we check the `fullName` , then replace it with `firstName` `lastName` . Line 133 in that snippet is totally useless

I had the same impression but I was not sure because I am not familiar with the Ruby syntax…
