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

Add SamlResponseXML method to profile object #330

Merged
merged 1 commit into from
Feb 8, 2019
Merged
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
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 @@ -608,7 +608,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 @@ -630,7 +630,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 @@ -860,7 +860,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 @@ -1023,6 +1023,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