Skip to content

Commit 638eae0

Browse files
committed
Add check for undefined UUID
This check is needed at there are tons of LDAP implementations out there and none has at least one guaranteed unique field. As we currently check three fields and added an option to select one yourself, it's still not said that any of these fields is set. This will now create an error and fail the authentication instead of letting people may get access to other people's notes which are stored under a this way deterministic wrong userid named `LDAP-undefined`. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
1 parent 9cbe03d commit 638eae0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/web/auth/ldap/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ passport.use(new LDAPStrategy({
2323
tlsOptions: config.ldap.tlsOptions || null
2424
}
2525
}, function (user, done) {
26-
var uuid = user.uidNumber || user.uid || user.sAMAccountName
26+
var uuid = user.uidNumber || user.uid || user.sAMAccountName || undefined
2727
if (config.ldap.useridField && user[config.ldap.useridField]) {
2828
uuid = user[config.ldap.useridField]
2929
}
3030

31+
if (typeof uuid === 'undefined') {
32+
throw new Error('Could not determine UUID for LDAP user. Check that ' +
33+
'either uidNumber, uid or sAMAccountName is set in your LDAP directory ' +
34+
'or use another unique attribute and configure it using the ' +
35+
'"useridField" option in ldap settings.')
36+
}
37+
3138
var username = uuid
3239
if (config.ldap.usernameField && user[config.ldap.usernameField]) {
3340
username = user[config.ldap.usernameField]

0 commit comments

Comments
 (0)