forked from node-saml/passport-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiSamlStrategy.js
More file actions
65 lines (50 loc) · 1.97 KB
/
multiSamlStrategy.js
File metadata and controls
65 lines (50 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var util = require('util');
var saml = require('./lib/passport-saml/saml');
var InMemoryCacheProvider = require('./lib/passport-saml/inmemory-cache-provider').CacheProvider;
var SamlStrategy = require('./lib/passport-saml/strategy');
function MultiSamlStrategy (options, verify) {
if (!options || typeof options.getSamlOptions != 'function') {
throw new Error('Please provide a getSamlOptions function');
}
if(!options.requestIdExpirationPeriodMs){
options.requestIdExpirationPeriodMs = 28800000; // 8 hours
}
if(!options.cacheProvider){
options.cacheProvider = new InMemoryCacheProvider(
{keyExpirationPeriodMs: options.requestIdExpirationPeriodMs });
}
SamlStrategy.call(this, options, verify);
this._options = options;
}
util.inherits(MultiSamlStrategy, SamlStrategy);
MultiSamlStrategy.prototype.authenticate = function (req, options) {
var self = this;
this._options.getSamlOptions(req, function (err, samlOptions) {
if (err) {
return self.error(err);
}
self._saml = new saml.SAML(Object.assign({}, self._options, samlOptions));
self.constructor.super_.prototype.authenticate.call(self, req, options);
});
};
MultiSamlStrategy.prototype.logout = function (req, options) {
var self = this;
this._options.getSamlOptions(req, function (err, samlOptions) {
if (err) {
return self.error(err);
}
self._saml = new saml.SAML(Object.assign({}, self._options, samlOptions));
self.constructor.super_.prototype.logout.call(self, req, options);
});
};
MultiSamlStrategy.prototype.generateServiceProviderMetadata = function( req, decryptionCert, signingCert, next ) {
var self = this;
return this._getSamlOptions(req, function (err, samlOptions) {
if (err) {
return next(err);
}
self._saml = new saml.SAML(samlOptions);
return next(null, self.constructor.super_.prototype.generateServiceProviderMetadata.call(self, decryptionCert, signingCert ));
});
};
module.exports = MultiSamlStrategy;