Skip to content

Commit

Permalink
Merge pull request #7721 from arminfelder/0.57.2-samlFix
Browse files Browse the repository at this point in the history
[FIX] meteor-accounts-saml issue with ns0,ns1 namespaces, makes it compatible with pysaml2 lib
  • Loading branch information
rodrigok committed Aug 21, 2017
2 parents 494b5a7 + 17321b7 commit 5b60751
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/meteor-accounts-saml/saml_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Accounts.saml.initiateLogin = function(options, callback, dimensions) {

Meteor.loginWithSaml = function(options, callback) {
options = options || {};
const credentialToken = Random.id();
const credentialToken = `id-${ Random.id() }`;
options.credentialToken = credentialToken;

Accounts.saml.initiateLogin(options, function(/*error, result*/) {
Expand Down
9 changes: 7 additions & 2 deletions packages/meteor-accounts-saml/saml_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SAML.prototype.initialize = function(options) {

SAML.prototype.generateUniqueID = function() {
const chars = 'abcdef0123456789';
let uniqueID = '';
let uniqueID = 'id-';
for (let i = 0; i < 20; i++) {
uniqueID += chars.substr(Math.floor((Math.random() * 15)), 1);
}
Expand Down Expand Up @@ -258,6 +258,10 @@ SAML.prototype.getElement = function(parentElement, elementName) {
return parentElement[`saml2p:${ elementName }`];
} else if (parentElement[`saml2:${ elementName }`]) {
return parentElement[`saml2:${ elementName }`];
} else if (parentElement[`ns0:${ elementName }`]) {
return parentElement[`ns0:${ elementName }`];
} else if (parentElement[`ns1:${ elementName }`]) {
return parentElement[`ns1:${ elementName }`];
}
return parentElement[elementName];
};
Expand Down Expand Up @@ -314,7 +318,8 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) {
console.log(`Validating response with relay state: ${ xml }`);
}
const parser = new xml2js.Parser({
explicitRoot: true
explicitRoot: true,
xmlns:true
});

parser.parseString(xml, function(err, doc) {
Expand Down

0 comments on commit 5b60751

Please sign in to comment.