handle extension for auth
This commit is contained in:
parent
73f26d6e05
commit
224c3ac9cd
|
@ -130,20 +130,30 @@ function applyConfig(config) {
|
||||||
, debug: state.config.debug || state.config.greenlock.debug
|
, debug: state.config.debug || state.config.greenlock.debug
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TODO specify extensions in config file
|
||||||
|
state.extensions = require('../lib/extensions');
|
||||||
|
} catch(e) {
|
||||||
|
if (state.debug) { console.log('[DEBUG] no extensions loaded', e); }
|
||||||
|
state.extensions = {};
|
||||||
|
}
|
||||||
require('../lib/handlers').create(state); // adds directly to config for now...
|
require('../lib/handlers').create(state); // adds directly to config for now...
|
||||||
|
|
||||||
//require('cluster-store').create().then(function (store) {
|
//require('cluster-store').create().then(function (store) {
|
||||||
//program.store = store;
|
//program.store = store;
|
||||||
|
|
||||||
|
|
||||||
state.authenticate = function (opts) {
|
state.authenticate = function (opts) {
|
||||||
try {
|
if (state.extensions.authenticate) {
|
||||||
state.extensions = require('./extensions');
|
try {
|
||||||
return state.extensions.authenticate({
|
return state.extensions.authenticate({
|
||||||
state: state
|
state: state
|
||||||
, auth: opts.auth
|
, auth: opts.auth
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// ignore
|
console.error('Extension Error:');
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return state.defaults.authenticate(opts.auth);
|
return state.defaults.authenticate(opts.auth);
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,9 +116,16 @@ module.exports.create = function (state) {
|
||||||
//
|
//
|
||||||
var serveAdmin = require('serve-static')(__dirname + '/../admin', { redirect: true });
|
var serveAdmin = require('serve-static')(__dirname + '/../admin', { redirect: true });
|
||||||
var finalhandler = require('finalhandler');
|
var finalhandler = require('finalhandler');
|
||||||
state.httpTunnelServer = http.createServer(function (req, res) {
|
state.defaults.webadmin = function (req, res) {
|
||||||
res.setHeader('connection', 'close');
|
|
||||||
serveAdmin(req, res, finalhandler(req, res));
|
serveAdmin(req, res, finalhandler(req, res));
|
||||||
|
};
|
||||||
|
state.httpTunnelServer = http.createServer(function (req, res) {
|
||||||
|
//res.setHeader('connection', 'close');
|
||||||
|
if (state.extensions.webadmin) {
|
||||||
|
state.extensions.webadmin(state, req, res);
|
||||||
|
} else {
|
||||||
|
state.defaults.webadmin(req, res);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Object.keys(state.tlsOptions).forEach(function (key) {
|
Object.keys(state.tlsOptions).forEach(function (key) {
|
||||||
tunnelAdminTlsOpts[key] = state.tlsOptions[key];
|
tunnelAdminTlsOpts[key] = state.tlsOptions[key];
|
||||||
|
|
Loading…
Reference in New Issue