Make protocol configurable

This commit is contained in:
Henri Bergius
2012-06-28 15:56:23 +02:00
parent 2e07afba22
commit 11f20d480f
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -39,7 +39,8 @@ passport.use(new SamlStrategy(
{
path: '/login/callback',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'passport-saml'
issuer: 'passport-saml',
protocol: 'http://'
},
function(profile, done) {
if (!profile.email) {
+6 -3
View File
@@ -9,6 +9,11 @@ SAML.prototype.initialize = function (options) {
if (!options) {
options = {};
}
if (!options.protocol) {
options.protocol = 'https://';
}
if (!options.path) {
options.path = '/saml/consume';
}
@@ -39,13 +44,11 @@ SAML.prototype.generateInstant = function () {
};
SAML.prototype.generateRequest = function (req) {
var http = "http://";
var https = "https://";
var id = "_" + this.generateUniqueID();
var instant = this.generateInstant();
// Post-auth destination
var callbackUrl = https + req.headers.host + this.options.path;
var callbackUrl = this.options.protocol + req.headers.host + this.options.path;
var request =
"<samlp:AuthnRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"" + id + "\" Version=\"2.0\" IssueInstant=\"" + instant + "\" ProtocolBinding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" AssertionConsumerServiceURL=\"" + callbackUrl + "\">" +