diff --git a/lib/routes/authenticate.js b/lib/routes/authenticate.js index da12a32..5c63575 100644 --- a/lib/routes/authenticate.js +++ b/lib/routes/authenticate.js @@ -2,10 +2,11 @@ import ldap from 'ldapjs'; import auth0 from 'auth0'; import logger from '../logger'; -export default function(domain, clientId) { +export default function(domain, clientId, clientSecret) { const client = new auth0.AuthenticationClient({ domain: domain, - clientId: clientId + clientId: clientId, + clientSecret: clientSecret }); return (req, res, next) => { @@ -17,7 +18,7 @@ export default function(domain, clientId) { return next(new ldap.InvalidDnSyntaxError(`The username '${req.dn.toString()}' does not match 'CN=username,OU=connection'`)); } - client.oauth.signIn({ username: parsedName[1], password: req.credentials, connection: parsedName[2] }) + client.oauth.passwordGrant({ username: parsedName[1], password: req.credentials, realm: parsedName[2] }) .then(() => { logger.info(`Bind success for ${req.dn.toString()}`); res.end(); diff --git a/server.js b/server.js index 420c5c2..2f3c8f3 100644 --- a/server.js +++ b/server.js @@ -17,7 +17,12 @@ nconf logger.info('Starting LDAP endpoint for Auth...'); const server = ldap.createServer(); -server.bind('', authenticate(nconf.get('AUTH0_DOMAIN'), nconf.get('AUTH0_CLIENT_ID'))); +server.bind('', authenticate( + nconf.get('AUTH0_DOMAIN'), + nconf.get('AUTH0_CLIENT_ID'), + nconf.get('AUTH0_CLIENT_SECRET') +)); + server.search('', requireAdministrator, search(nconf.get('AUTH0_DOMAIN'), nconf.get('AUTH0_API_TOKEN'))); server.listen(nconf.get('LDAP_PORT'), () => { logger.info(`LDAP server listening on: ${server.url}`);