Skip to content

Commit

Permalink
Add SamlResponseXML method to profile object
Browse files Browse the repository at this point in the history
This add the ability to extract the original SamlResponseXML as a method in the profile object.
  • Loading branch information
josecolella authored and markstos committed Feb 8, 2019
1 parent e2154f2 commit 0544376
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Profile = {
email?: string; // `mail` if not present in the assertion
getAssertionXml(): string; // get the raw assertion XML
getAssertion(): object; // get the assertion XML parsed as a JavaScript object
getSamlResponseXml(): string; // get the raw SAML response XML
ID?: string;
} & {
[attributeName: string]: string; // arbitrary `AttributeValue`s
Expand Down
7 changes: 4 additions & 3 deletions lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ SAML.prototype.validatePostResponse = function (container, callback) {
!self.validateSignature(xml, assertions[0], certs)) {
throw new Error('Invalid signature');
}
return self.processValidlySignedAssertion(assertions[0].toString(), inResponseTo, callback);
return self.processValidlySignedAssertion(assertions[0].toString(), xml, inResponseTo, callback);
}

if (encryptedAssertions.length == 1) {
Expand All @@ -633,7 +633,7 @@ SAML.prototype.validatePostResponse = function (container, callback) {
!self.validateSignature(decryptedXml, decryptedAssertions[0], certs))
throw new Error('Invalid signature from encrypted assertion');

self.processValidlySignedAssertion(decryptedAssertions[0].toString(), inResponseTo, callback);
self.processValidlySignedAssertion(decryptedAssertions[0].toString(), xml, inResponseTo, callback);
});
}

Expand Down Expand Up @@ -863,7 +863,7 @@ SAML.prototype.verifyIssuer = function (samlMessage) {
}
};

SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callback) {
SAML.prototype.processValidlySignedAssertion = function(xml, samlResponseXml, inResponseTo, callback) {
var self = this;
var msg;
var parserConfig = {
Expand Down Expand Up @@ -1026,6 +1026,7 @@ SAML.prototype.processValidlySignedAssertion = function(xml, inResponseTo, callb

profile.getAssertionXml = function() { return xml; };
profile.getAssertion = function() { return parsedAssertion; };
profile.getSamlResponseXml = function() { return samlResponseXml; };

callback(null, profile, false);
})
Expand Down

0 comments on commit 0544376

Please sign in to comment.