Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit f0b7687

Browse files
ganeshrajsekarGanesh Rajasekar
andauthored
[ULP-3649][ULP-3712] Fix: URL fragments in SAML Sign in URLs (auth0#171)
* fix: SAML request url construction with query and fragment * fix: Add tests for SAML request URL construction * fix: Change order of split for URL parsing and add tests Co-authored-by: Ganesh Rajasekar <[email protected]>
1 parent 8caadc9 commit f0b7687

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

lib/passport-wsfed-saml2/samlp.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ Samlp.prototype = {
245245
if (err) return callback(err);
246246

247247
var parsedUrl = url.parse(options.identityProviderUrl, true);
248-
var samlRequestUrl = options.identityProviderUrl.split('?')[0] + '?' + qs.encode(xtend(parsedUrl.query, params));
248+
var samlRequestUrl = stripQueryAndFragmentFromURL(options.identityProviderUrl) + '?' + qs.encode(xtend(parsedUrl.query, params));
249+
if (parsedUrl.hash !== null) {
250+
samlRequestUrl += parsedUrl.hash;
251+
}
249252
return callback(null, samlRequestUrl);
250253
});
251254
},
@@ -501,3 +504,7 @@ function generateInstant() {
501504
var date = new Date();
502505
return date.getUTCFullYear() + '-' + ('0' + (date.getUTCMonth()+1)).slice(-2) + '-' + ('0' + date.getUTCDate()).slice(-2) + 'T' + ('0' + date.getUTCHours()).slice(-2) + ":" + ('0' + date.getUTCMinutes()).slice(-2) + ":" + ('0' + date.getUTCSeconds()).slice(-2) + "Z";
503506
}
507+
508+
function stripQueryAndFragmentFromURL(url) {
509+
return url.split("#")[0].split("?")[0];
510+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "passport-wsfed-saml2",
3-
"version": "4.6.1",
3+
"version": "4.6.2",
44
"description": "SAML2 Protocol and WS-Fed library",
55
"scripts": {
66
"test": "./node_modules/.bin/mocha --recursive",

test/samlp.tests.js

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)