Skip to content
This repository was archived by the owner on Jul 3, 2026. It is now read-only.

Commit 53dbf58

Browse files
author
Fady Makram
authored
[IPS-1946] Fix uncaught with missing serviceProviderLogoutURL (#123)
1 parent a1ba91a commit 53dbf58

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

lib/logout.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,12 @@ function prepareAndSendToken(req, res, element_type, token, options, cb) {
312312
}
313313

314314
// HTTP-Redirect
315-
var samlResponseUrl = utils.appendQueryString(options.destination, params);
316-
res.redirect(samlResponseUrl);
315+
try {
316+
const samlResponseUrl = utils.appendQueryString(options.destination, params);
317+
res.redirect(samlResponseUrl);
318+
} catch (e) {
319+
cb(new Error('The logout URL may be missing or misconfigured'));
320+
}
317321
};
318322

319323
var params = {};

test/samlp.logout.session_store.tests.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,36 @@ describe('samlp logout with Session Participants - Session Provider', function (
770770
});
771771
});
772772
});
773+
774+
describe('SP initiated - When the SessionParticipant does not have a configured serviceProviderLogoutURL', function () {
775+
before(function () {
776+
sessions.splice(0);
777+
const sessionParticipantWithoutDestination = { ...sessionParticipant1 };
778+
delete sessionParticipantWithoutDestination.serviceProviderLogoutURL;
779+
sessions.push(sessionParticipantWithoutDestination);
780+
});
781+
782+
// SAMLRequest: base64 encoded + deflated + URLEncoded
783+
// Signature: URLEncoded
784+
// SigAlg: URLEncoded
785+
786+
// <samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="samlr-220c705e-c15e-11e6-98a4-ecf4bbce4318" IssueInstant="2016-12-13T18:01:12Z" Version="2.0">
787+
// <saml:Issuer>https://foobarsupport.zendesk.com</saml:Issuer>
788+
// <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">foo@example.com</saml:NameID>
789+
// <saml:SessionIndex>1</saml:SessionIndex>
790+
// </samlp:LogoutRequest>
791+
it('should respond with an error', function (done) {
792+
request.get({
793+
followRedirect: false,
794+
uri: 'http://localhost:5050/logout?SAMLRequest=fVFNS8NAEL0L%2Foew900zaa1xaIOFIgSqBysevG03Uw1md%2BPOBoq%2F3m1aoVZ0DnOY97WPnbEybYcr9%2Br68EgfPXFIdqa1jAMyF7236BQ3jFYZYgwa14v7FeZphp13wWnXihPJ%2FwrFTD40zoqkWs7FXuBlnmf6OrsiqSEuAJrKm0JNJOntZLPRNBlDEfnMPVWWg7JhLvIMphJyCeMnKDADhPxFJM%2FkOZpHOM1EeXmRHGe2D8LBwZdvIXSMo9HWuY3y3Hed8yH9JFsTv6famdnolH7u8hBLVcvkznmjwt9tIYXh0tRyO1CRjGraRV17YhZlTL%2BlnTJdSyeZB%2FNfmesoib2q%2BMRdCUfuj%2BO34oCd%2FWj5BQ%3D%3D&Signature=NkobB0DS0M4kfV89R%2Bma0wp0djNr4GW2ziVemwSvVYy2iF432qjs%2FC4Y1cZDXwuF5OxMgu4DuelS5mW3Z%2B46XXkoMVBizbd%2BIuJUFQcvLtiXHkoaEk8HVU0v5bA9TDoc9Ve7A0nUgKPciH7KTcFSr45vepyg0dMMQtarsUZeYSRPM0QlwxXKCWRQJDwGHLie5dMCZTRNUEcm9PtWZij714j11HI15u6Fp5GDnhp7mzKuAUdSIKHzNKAS2J4S8xZz9n9UTCl3uBbgfxZ3av6%2FMQf7HThxTl%2FIOmU%2FYCAN6DWWE%2BQ3Z11bgU06P39ZuLW2fRBOfIOO6iTEaAdORrdBOw%3D%3D&RelayState=123&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1'
795+
}, (err, response) => {
796+
if (err) return done(err);
797+
expect(response.statusCode).to.equal(400);
798+
expect(response.body).to.equal('The logout URL may be missing or misconfigured');
799+
done();
800+
});
801+
});
802+
});
773803
});
774804

775805
describe('HTTP POST', function () {

0 commit comments

Comments
 (0)