Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions lib/samlp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var xtend = require('xtend');
var utils = require('./utils');
var templates = require('./templates');
var encoders = require('./encoders');
var signers = require('./signers');
var PassportProfileMapper = require('./claims/PassportProfileMapper');
var constants = require('./constants');

Expand All @@ -29,27 +30,8 @@ function buildSamlResponse(options) {
.replace(/>(\s*)</g, '><') //unindent
.trim();

var sig = new SignedXml(null, {
signatureAlgorithm: constants.ALGORITHMS.SIGNATURE[options.signatureAlgorithm]
});

sig.addReference(
constants.ELEMENTS.RESPONSE.SIGNATURE_LOCATION_PATH,
["http://www.w3.org/2000/09/xmldsig#enveloped-signature", "http://www.w3.org/2001/10/xml-exc-c14n#"],
constants.ALGORITHMS.DIGEST[options.digestAlgorithm]);

sig.signingKey = options.key;

var pem = encoders.removeHeaders(options.cert);
sig.keyInfoProvider = {
getKeyInfo: function (key, prefix) {
prefix = prefix ? prefix + ':' : prefix;
return "<" + prefix + "X509Data><" + prefix + "X509Certificate>" + pem + "</" + prefix + "X509Certificate></" + prefix + "X509Data>";
}
};

sig.computeSignature(cannonicalized, { prefix: options.signatureNamespacePrefix, location: { action: 'after', reference: "//*[local-name(.)='Issuer']" }});
SAMLResponse = sig.getSignedXml();
options.reference = constants.ELEMENTS.RESPONSE.SIGNATURE_LOCATION_PATH;
return signers.signXml(options, cannonicalized);
}

return SAMLResponse;
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "samlp",
"version": "3.4.0",
"version": "3.4.1",
"description": "SAML Protocol server middleware",
"main": "lib/index.js",
"scripts": {
Expand All @@ -20,24 +20,24 @@
"license": "mit",
"dependencies": {
"@auth0/thumbprint": "0.0.6",
"ejs": "2.5.5",
"ejs": "2.6",
"flowstate": "^0.4.0",
"querystring": "^0.2.0",
"saml": "^0.12.1",
"xml-crypto": "^0.10.1",
"xmldom": "auth0/xmldom#v0.1.19-auth0_1",
"xpath": "0.0.5",
"xtend": "^1.0.3"
"saml": "0.13",
"xml-crypto": "1.4",
"xmldom": "github:auth0/xmldom#v0.1.19-auth0_1",
"xpath": "0.0.27",
"xtend": "4"
},
"devDependencies": {
"body-parser": "^1.15.2",
"chai": "~1.5.0",
"cheerio": "~0.10.7",
"express": "~3.1.0",
"express-session": "^1.14.2",
"istanbul": "^0.4.5",
"mocha": "~1.8.1",
"request": "~2.14.0",
"uid2": "0.0.3"
"body-parser": "^1",
"chai": "4",
"cheerio": "^0.22.0",
"express": "^3",
"express-session": "^1",
"istanbul": "^0.4",
"mocha": "1",
"request": "~2.14",
"uid2": "0"
}
}
2 changes: 1 addition & 1 deletion test/samlp.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ describe('samlp', function () {

it('should return signature with the specified signatureNamespacePrefix inside the response', function(){
var doc = new xmldom.DOMParser().parseFromString(samlResponse);
var signature = doc.documentElement.getElementsByTagName('ds:Signature');
var signature = doc.documentElement.getElementsByTagName('Signature');
expect(signature[0].parentNode.nodeName).to.equal('samlp:Response');
});
});
Expand Down