-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (33 loc) · 900 Bytes
/
index.js
File metadata and controls
43 lines (33 loc) · 900 Bytes
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
var _ = require('lodash');
var samlHapi = require('./saml-hapi');
var internals = {};
exports.register = function(plugin, options, next) {
plugin.auth.scheme('saml', internals.implementation);
var settings = _.clone(options);
var path = settings.path || "/SAML";
// Add callback route
plugin.route({
// NOTE: needs to be '*'
method: '*',
path: path,
config: {
auth: false,
handler: function(request, reply) {
plugin.log(['debug', 'callback'], JSON.stringify(request.auth));
// Run authentication
samlHapi.authenticate(settings)(request, reply);
}
}
});
next();
};
exports.register.attributes = {
pkg: require('../package.json')
};
internals.implementation = function(server, options) {
var settings = _.clone(options);
var scheme = {
authenticate: samlHapi.authenticate(settings)
};
return scheme;
};