From 4413a4ac7414f6f58d95f158a18b7bfbdded9afa Mon Sep 17 00:00:00 2001 From: Guillaume WANG <guillaume.wang@polytechnique.edu> Date: Wed, 30 Jan 2019 01:58:07 +0100 Subject: [PATCH] fixed ldap config import in config_passport --- src/adminview/admin_router.ts | 3 ++- src/app.ts | 17 +++++++++++++++-- src/config_passport.js | 7 ++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/adminview/admin_router.ts b/src/adminview/admin_router.ts index 4f0ffa6..b75e26b 100644 --- a/src/adminview/admin_router.ts +++ b/src/adminview/admin_router.ts @@ -241,7 +241,8 @@ router.use((req, res, next) => { */ router.use((err, req, res, next) => { console.log("adminview: Entering error handler"); - console.log(err.message); + console.log(err); + //console.log(err.message); //res.status(err.status || 500); res.render('error', { diff --git a/src/app.ts b/src/app.ts index bf134c5..cbe1299 100644 --- a/src/app.ts +++ b/src/app.ts @@ -208,8 +208,19 @@ const context = async ({ req }): Promise<Context> => { console.log(err); } } - - return { + console.log(`Constructing context with uid = ${uid}`); + /*return { + request: req, + user: { uid: uid }, + models: { + auth: await AuthorizationModel.create(uid), + user: new UserModel(uid), + group: new GroupModel(uid), + message: new MessageModel(uid), + request: new RequestModel(uid) + } + };*/ + let blah = { request: req, user: { uid: uid }, models: { @@ -220,6 +231,8 @@ const context = async ({ req }): Promise<Context> => { request: new RequestModel(uid) } }; + console.log("finished constructing context"); + return blah; }; const server = new ApolloServer({ diff --git a/src/config_passport.js b/src/config_passport.js index c9b9a85..d82f49b 100644 --- a/src/config_passport.js +++ b/src/config_passport.js @@ -40,10 +40,11 @@ passport.use(new LdapStrategy({ url: ldapConfig.server, //bindDn: '.............', //bindCredentials: '..........', - // searchBase: ldapConfig.searchBase, TODO: this cannot be left empty. - // searchFilter: ldapConfig.searchFilter, TODO: this cannot be left empty. - //searchAttributes: ['givenName', 'sn'], + searchBase: ldapConfig.dn_users, // this field cannot be left empty. + searchFilter: '(uid={{username}})', // this field cannot be left empty. + searchAttributes: ['uid', 'urlPhoto'], // only fetch the uid, no need for any other field //tlsOptions: '..........', + //https://www.npmjs.com/package/passport-ldapauth for more }, //usernameField: 'username', // Field name where the username is found, defaults to username //passwordField: 'password', // Field name where the password is found, defaults to password -- GitLab