RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.54k stars 10.57k forks source link

SAML + xmlbuilder-js: problem with setting mdui:UIInfo #7081

Closed localguru closed 7 years ago

localguru commented 7 years ago

Rocket.Chat Version: 0.56.0 Running Instances: 1 DB Replicaset OpLog: enabled Node Version: 0.45

Hi,

for a shibb IdP I'd like to generate something like this on /_saml/metadata/xyz

      <mdui:UIInfo>
        <mdui:DisplayName xml:lang="de">Mein Titel</mdui:DisplayName>
        <mdui:DisplayName xml:lang="en">My title</mdui:DisplayName>
        <mdui:Description xml:lang="de">Ein Test</mdui:Description>
        <mdui:Description xml:lang="en">a test</mdui:Description>
      </mdui:UIInfo>

My js code in ./programs/server/packages/steffo_meteor-accounts-saml.js:

 'mdui:UIInfo': {
   'mdui:DisplayName': { '@xml:lang': 'de', '#text': 'Mein Titel' },
   'mdui:DisplayName': { '@xml:lang': 'en', '#text': 'My title' },
   'mdui:Description': { '@xml:lang': 'de', '#text': 'Ein Test' },
   'mdui:Description': { '@xml:lang': 'en', '#text': 'A test' },
 }

This code ends up in just one element of DisplayName and Description:

      <mdui:UIInfo>
        <mdui:DisplayName xml:lang="en">My title</mdui:DisplayName>
        <mdui:Description xml:lang="en">a test</mdui:Description>
      </mdui:UIInfo>

I've posted a ticket on https://github.com/oozcitak/xmlbuilder-js/issues/159 but if I understand it right, with xmlbuilder-js above code can't work, because JS objects cannot have duplicate keys .

Any ideas how to fix it, because I'd like to offer DisplayName and Description in different languages.

Ciao! M.

localguru commented 7 years ago

Another try, but it's not working:

                                  'mdui:UIInfo': {
                                    "mdui:DisplayName": [
                                      {
                                        "@xml:lang": "de",
                                        "#text": "AAA"
                                      },
                                      {
                                        "@xml:lang": "en",
                                        "#text": "BBB"
                                      }
                                    ],

Output is

<mdui:DisplayName xml:lang="en">AAA  BBB</mdui:DisplayName>
localguru commented 7 years ago

That code is working:

        var metadata = {
                'EntityDescriptor': {
                        '@xmlns': 'urn:oasis:names:tc:SAML:2.0:metadata',
                        '@xmlns:ds': 'http://www.w3.org/2000/09/xmldsig#',
                        '@xmlns:mdui': 'urn:oasis:names:tc:SAML:metadata:ui',
                        '@entityID': this.options.issuer,
                        'SPSSODescriptor': {
                                '@protocolSupportEnumeration': 'urn:oasis:names:tc:SAML:2.0:protocol',
                                'Extensions': {
                                  'mdui:UIInfo':
                                    [
                                      { 'mdui:DisplayName': { "@xml:lang": "de", "#text": "Mein Titel" } },
                                      { 'mdui:DisplayName': { "@xml:lang": "en", "#text": "My title" } },
                                      { 'mdui:Description': { "@xml:lang": "de", "#text": "Ein Test" } },
                                      { 'mdui:Description': { "@xml:lang": "en", "#text": "a test" } },
                                      { 'mdui:Logo': { '@height': '85', '@width': '436', '#text': 'https://yourdomain.tld/assets/logo.svg' } },
                                    ]
                                },
                                'KeyDescriptor': keyDescriptor,