Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

add athenticationMethod support #6

Merged
merged 2 commits into from
Oct 16, 2018
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
41 changes: 0 additions & 41 deletions server/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,6 @@ import util from 'util';
import Bunyan from 'bunyan';
import { log_debug, log_info, log_warn, log_error } from './logger';


// Use them to test the ldap withn't use snap
// process.env.LDAP_ENABLE = 'true';
// process.env.LDAP_PORT = '389';
// process.env.LDAP_HOST = '';
// process.env.LDAP_BASEDN = '';
// process.env.LDAP_LOGIN_FALLBACK = 'false';
// process.env.LDAP_RECONNECT = 'true';
// process.env.LDAP_TIMEOUT = '10000';
// process.env.LDAP_IDLE_TIMEOUT = '10000';
// process.env.LDAP_CONNECT_TIMEOUT = '10000';
// process.env.LDAP_AUTHENTIFICATION = 'true';
// process.env.LDAP_AUTHENTIFICATION_USERDN = '';
// process.env.LDAP_AUTHENTIFICATION_PASSWORD = '';
// process.env.LDAP_BACKGROUND_SYNC = 'false';
// process.env.LDAP_BACKGROUND_SYNC_INTERVAL = '100';
// process.env.LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED = 'false';
// process.env.LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS = 'false';
// process.env.LDAP_ENCRYPTION = 'false';
// process.env.LDAP_CA_CERT = '';
// process.env.LDAP_REJECT_UNAUTHORIZED = 'false';
// process.env.LDAP_USER_SEARCH_FILTER = '';
// process.env.LDAP_USER_SEARCH_SCOPE = '';
// process.env.LDAP_USER_SEARCH_FIELD = '';
// process.env.LDAP_SEARCH_PAGE_SIZE = '0';
// process.env.LDAP_SEARCH_SIZE_LIMIT = '0';
// process.env.LDAP_GROUP_FILTER_ENABLE = 'false';
// process.env.LDAP_GROUP_FILTER_OBJECTCLASS = '';
// process.env.LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE = '';
// process.env.LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE = '';
// process.env.LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT = '';
// process.env.LDAP_GROUP_FILTER_GROUP_NAME = '';
// process.env.LDAP_UNIQUE_IDENTIFIER_FIELD = '';
// process.env.LDAP_UTF8_NAMES_SLUGIFY = 'true';
// process.env.LDAP_USERNAME_FIELD = '';
// process.env.LDAP_MERGE_EXISTING_USERS = 'false';
// process.env.LDAP_SYNC_USER_DATA = 'false';
// process.env.LDAP_SYNC_USER_DATA_FIELDMAP = '';
// process.env.LDAP_SYNC_GROUP_ROLES = '';
// process.env.LDAP_DEFAULT_DOMAIN = '';

export default class LDAP {
constructor(){
this.ldapjs = ldapjs;
Expand Down
3 changes: 2 additions & 1 deletion server/logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const isLogEnabled = (process.env.LDAP_INTERNAL_LOG_LEVEL === 'true');
const isLogEnabled = (process.env.LDAP_LOG_ENABLED === 'true');


function log (level, message, data) {
if (isLogEnabled) {
Expand Down
6 changes: 2 additions & 4 deletions server/loginHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {

// Login user if they exist
if (user) {
if (user.ldap !== true && LDAP.settings_get('LDAP_MERGE_EXISTING_USERS') !== true) {
log_info('User exists without "ldap: true"');
if (user.authenticationMethod !== 'ldap' && LDAP.settings_get('LDAP_MERGE_EXISTING_USERS') !== true) {
log_info('User exists without "authenticationMethod : ldap"');
throw new Meteor.Error('LDAP-login-error', `LDAP Authentication succeded, but there's already an existing user with provided username [${ username }] in Mongo.`);
}

Expand Down Expand Up @@ -171,7 +171,5 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
throw result;
}

console.log('RESULT : ', result);

return result;
});
4 changes: 2 additions & 2 deletions server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function getDataToSyncUserData(ldapUser, user) {
userData['services.ldap.idAttribute'] = uniqueId.attribute;
}

if (user.ldap !== true) {
if (user.authenticationMethod !== 'ldap') {
userData.ldap = true;
}

Expand Down Expand Up @@ -260,7 +260,7 @@ export function addLdapUser(ldapUser, username, password) {
$set: {
'services.ldap': { id: uniqueId.value },
'emails.0.verified': true,
ldap: true,
'authenticationMethod': 'ldap',
}});
} catch (error) {
log_error('Error creating user', error);
Expand Down