Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions app/ldap/server/loginHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
}

if (ldapUser === undefined) {
if (settings.get('LDAP_Login_Fallback') === true) {
return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass);
}

throw new Meteor.Error('LDAP-login-error', `LDAP Authentication failed with provided username [${ loginRequest.username }]`);
return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass);
}

// Look to see if user already exists
Expand Down Expand Up @@ -120,7 +116,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
if (user) {
if (user.ldap !== true && settings.get('LDAP_Merge_Existing_Users') !== true) {
logger.info('User exists without "ldap: true"');
throw new Meteor.Error('LDAP-login-error', `LDAP Authentication succeded, but there's already an existing user with provided username [${ username }] in Mongo.`);
throw new Meteor.Error('LDAP-login-error', `LDAP Authentication succeeded, but there's already an existing user with provided username [${ username }] in Mongo.`);
}

logger.info('Logging user');
Expand Down Expand Up @@ -156,3 +152,19 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {

return result;
});

callbacks.add('beforeValidateLogin', (login) => {
if (!login.allowed) {
return login;
}

if (login.type === 'ldap') {
return login;
}

if (login.user.services && login.user.services.ldap && login.user.services.ldap.id) {
login.allowed = !!settings.get('LDAP_Login_Fallback');
}

return login;
});
2 changes: 1 addition & 1 deletion app/ldap/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ settings.addGroup('LDAP', function() {
];

this.add('LDAP_Enable', false, { type: 'boolean', public: true });
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery });
this.add('LDAP_Login_Fallback', false, { type: 'boolean', enableQuery: null });
this.add('LDAP_Find_User_After_Login', true, { type: 'boolean', enableQuery });
this.add('LDAP_Host', '', { type: 'string', enableQuery });
this.add('LDAP_Port', '389', { type: 'string', enableQuery });
Expand Down