forked from auth0/ad-ldap-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
72 lines (50 loc) · 1.61 KB
/
server.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require('colors');
require('./eventlog');
process.on('uncaughtException', function(err) {
console.error(err);
});
require('./lib/initConf');
var nconf = require('nconf');
var connectorSetup = require('./connector-setup');
var emptyVars = [ 'LDAP_URL',
'LDAP_BASE',
'LDAP_BIND_USER',
'LDAP_BIND_PASSWORD' ];
connectorSetup.run(__dirname, emptyVars, function(err) {
if(err) {
console.log(err.message);
process.exit(2);
}
if(!nconf.get('LDAP_URL')) {
console.error('edit config.json and add your LDAP settings');
return process.exit(1);
}
require('./ws_validator');
if (!nconf.get('KERBEROS_AUTH') || process.platform !== 'win32') {
return;
}
var kerberosServer = require('kerberos-server');
var express = require('express');
var passport = require('passport');
require('./lib/setupPassport');
var cookieSessions = require('cookie-sessions');
var app = express();
//configure the webserver
app.configure(function(){
this.set('view engine', 'ejs');
this.set('views', __dirname + '/views');
this.use(express.static(__dirname + '/public'));
this.use(express.logger());
this.use(express.cookieParser());
this.use(express.bodyParser());
this.use(cookieSessions({
session_key: 'auth0-ad-conn',
secret: nconf.get('SESSION_SECRET')
}));
this.use(passport.initialize());
this.use(this.router);
});
require('./endpoints').install(app);
kerberosServer.createServer(nconf.get('PORT'), app);
console.log('listening on http://localhost:' + nconf.get('PORT'));
});