From ec377bde9252bd6fd1305fc4c1d5ea7512d37212 Mon Sep 17 00:00:00 2001 From: "Pierre H. Lehnen" Date: Wed, 4 Jul 2018 14:02:16 -0300 Subject: [PATCH] Fixes issues with SAML attribute mapping (#11315) --- packages/meteor-accounts-saml/saml_utils.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/meteor-accounts-saml/saml_utils.js b/packages/meteor-accounts-saml/saml_utils.js index e1274111ba67..d749f02e9ddc 100644 --- a/packages/meteor-accounts-saml/saml_utils.js +++ b/packages/meteor-accounts-saml/saml_utils.js @@ -395,8 +395,7 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) { if (attributes) { attributes.forEach(function(attribute) { const value = self.getElement(attribute, 'AttributeValue'); - let key = attribute.$.Name.value; - key=key.replace(/\./g, '-'); + const key = attribute.$.Name.value; if (typeof value[0] === 'string') { profile[key] = value[0]; } else { @@ -422,6 +421,16 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) { console.log(`NameID: ${ JSON.stringify(profile) }`); } + const profileKeys = Object.keys(profile); + for (let i = 0; i < profileKeys.length; i++) { + const key = profileKeys[i]; + + if (key.match(/\./)) { + profile[key.replace(/\./g, '-')] = profile[key]; + delete profile[key]; + } + } + callback(null, profile, false); } else { const logoutResponse = self.getElement(doc, 'LogoutResponse');