forked from vrk-kpa/suomifi-passport-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiSamlStrategy.js
42 lines (32 loc) · 1.12 KB
/
multiSamlStrategy.js
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
var util = require('util');
var saml = require('./lib/passport-saml/saml');
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');
}
SamlStrategy.call(this, options, verify);
this._getSamlOptions = options.getSamlOptions;
}
util.inherits(MultiSamlStrategy, SamlStrategy);
MultiSamlStrategy.prototype.authenticate = function (req, options) {
var self = this;
this._getSamlOptions(req, function (err, samlOptions) {
if (err) {
return self.error(err);
}
self._saml = new saml.SAML(samlOptions);
self.constructor.super_.prototype.authenticate.call(self, req, options);
});
};
MultiSamlStrategy.prototype.logout = function (req, options) {
var self = this;
this._getSamlOptions(req, function (err, samlOptions) {
if (err) {
return self.error(err);
}
self._saml = new saml.SAML(samlOptions);
self.constructor.super_.prototype.logout.call(self, req, options);
});
};
module.exports = MultiSamlStrategy;