Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing in idAttribute as an option to validateSignature #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ saml.validate = function validate(rawAssertion, options, cb) {
var isSignatureValid = false;

try {
isSignatureValid = validateSignature(rawAssertion, options.publicKey, options.thumbprint);
isSignatureValid = validateSignature(rawAssertion, options.publicKey, options.thumbprint, options.idAttribute);
}
catch (e) {
var error = new Error('Invalid assertion.');
Expand Down
4 changes: 2 additions & 2 deletions lib/validateSignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ var SignedXml = require('xml-crypto').SignedXml;
var dom = require('xmldom').DOMParser;
var thumbprint = require('thumbprint');

module.exports = function validateSignature(xml, cert, certThumbprint) {
module.exports = function validateSignature(xml, cert, certThumbprint, idAttribute) {
var doc = new dom().parseFromString(xml);
var signature = select(doc, '/*/*/*[local-name(.)=\'Signature\' and namespace-uri(.)=\'http://www.w3.org/2000/09/xmldsig#\']')[0]
|| select(doc, '/*/*[local-name(.)=\'Signature\' and namespace-uri(.)=\'http://www.w3.org/2000/09/xmldsig#\']')[0];
var signed = new SignedXml(null, {
idAttribute: 'AssertionID'
idAttribute: idAttribute ? idAttribute : 'AssertionID'
});

var calculatedThumbprint;
Expand Down