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

[ULP-3649][ULP-3712] Fix: URL fragments in SAML Sign in URLs #171

Merged
merged 3 commits into from
Jun 29, 2022
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
9 changes: 8 additions & 1 deletion lib/passport-wsfed-saml2/samlp.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ Samlp.prototype = {
if (err) return callback(err);

var parsedUrl = url.parse(options.identityProviderUrl, true);
var samlRequestUrl = options.identityProviderUrl.split('?')[0] + '?' + qs.encode(xtend(parsedUrl.query, params));
var samlRequestUrl = stripQueryAndFragmentFromURL(options.identityProviderUrl) + '?' + qs.encode(xtend(parsedUrl.query, params));
if (parsedUrl.hash !== null) {
samlRequestUrl += parsedUrl.hash;
}
return callback(null, samlRequestUrl);
});
},
Expand Down Expand Up @@ -501,3 +504,7 @@ function generateInstant() {
var date = new Date();
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";
}

function stripQueryAndFragmentFromURL(url) {
return url.split("#")[0].split("?")[0];
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "passport-wsfed-saml2",
"version": "4.6.1",
"version": "4.6.2",
"description": "SAML2 Protocol and WS-Fed library",
"scripts": {
"test": "./node_modules/.bin/mocha --recursive",
Expand Down
32 changes: 32 additions & 0 deletions test/samlp.tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.