Skip to content

Commit

Permalink
Closes #2218; LDAP: Add a setting to disable avatar sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Feb 19, 2016
1 parent e16c8ff commit 325fed3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 45 deletions.
1 change: 1 addition & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"LDAP_Port" : "Port",
"LDAP_Port_Description" : "Port to access LDAP. eg: `389` or `636` for LDAPS",
"LDAP_Reject_Unauthorized" : "Reject Unauthorized",
"LDAP_Sync_User_Avatar" : "Sync User Avatar",
"LDAP_Sync_User_Data" : "Sync Data",
"LDAP_Sync_User_Data_Description" : "Keep user data in sync with server on login (eg: name, email).",
"LDAP_Sync_User_Data_FieldMap" : "User Data Field Map",
Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-ldap/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Package.onUse(function(api) {
api.use('rocketchat:lib');
api.use('tap:i18n');
api.use('yasaricli:slugify');
api.use('coffeescript');
api.use('ecmascript');
api.use('sha');

Expand All @@ -27,7 +26,7 @@ Package.onUse(function(api) {
api.addFiles('server/ldap.js', 'server');
api.addFiles('server/sync.js', 'server');
api.addFiles('server/loginHandler.js', 'server');
api.addFiles('server/settings.coffee', 'server');
api.addFiles('server/settings.js', 'server');
api.addFiles('server/testConnection.js', 'server');
api.addFiles('server/syncUsers.js', 'server');

Expand Down
42 changes: 0 additions & 42 deletions packages/rocketchat-ldap/server/settings.coffee

This file was deleted.

45 changes: 45 additions & 0 deletions packages/rocketchat-ldap/server/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Meteor.startup(function() {
RocketChat.settings.addGroup('LDAP', function() {
const enableQuery = {_id: 'LDAP_Enable', value: true};
const enableTLSQuery = [
{_id: 'LDAP_Enable', value: true},
{_id: 'LDAP_Encryption', value: {$in: ['tls', 'ssl']}}
];
const customBindSearchEnabledQuery = [
{_id: 'LDAP_Enable', value: true},
{_id: 'LDAP_Use_Custom_Domain_Search', value: true}
];
const customBindSearchDisabledQuery = [
{_id: 'LDAP_Enable', value: true},
{_id: 'LDAP_Use_Custom_Domain_Search', value: false}
];
const syncDataQuery = [
{_id: 'LDAP_Enable', value: true},
{_id: 'LDAP_Sync_User_Data', value: true}
];

this.add('LDAP_Enable', false, { type: 'boolean', public: true });
this.add('LDAP_Host', '', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Port', '389', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], enableQuery: enableQuery });
this.add('LDAP_CA_Cert', '', { type: 'string', multiline: true, enableQuery: enableTLSQuery });
this.add('LDAP_Reject_Unauthorized', true, { type: 'boolean', enableQuery: enableTLSQuery });
this.add('LDAP_Domain_Base', '', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Use_Custom_Domain_Search', false, { type: 'boolean' , enableQuery: enableQuery });
this.add('LDAP_Custom_Domain_Search', '', { type: 'string' , enableQuery: customBindSearchEnabledQuery });
this.add('LDAP_Domain_Search_User', '', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Password', '', { type: 'password', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Filter', '', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_User_ID', 'sAMAccountName', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Object_Class', 'user', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Object_Category', 'person', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Username_Field', 'sAMAccountName', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Unique_Identifier_Field', 'objectGUID,ibm-entryUUID,GUID,dominoUNID,nsuniqueId,uidNumber', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Sync_User_Data', false, { type: 'boolean' , enableQuery: enableQuery });
this.add('LDAP_Sync_User_Avatar', true, { type: 'boolean' , enableQuery: syncDataQuery });
this.add('LDAP_Sync_User_Data_FieldMap', '{"cn":"name", "mail":"email"}', { type: 'string', enableQuery: syncDataQuery });
this.add('LDAP_Default_Domain', '', { type: 'string' , enableQuery: enableQuery });
this.add('LDAP_Test_Connection', 'ldap_test_connection', { type: 'action', actionText: 'Test_Connection' });
this.add('LDAP_Sync_Users', 'ldap_sync_users', { type: 'action', actionText: 'Sync_Users' });
});
});
2 changes: 1 addition & 1 deletion packages/rocketchat-ldap/server/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ syncUserData = function syncUserData(user, ldapUser) {
logger.debug('setting', JSON.stringify(userData, null, 2));
}

if (user && user._id) {
if (user && user._id && RocketChat.settings.get('LDAP_Sync_User_Avatar') === true) {
const avatar = ldapUser.raw.thumbnailPhoto || ldapUser.raw.jpegPhoto;
if (avatar) {
logger.info('Syncing user avatar');
Expand Down

0 comments on commit 325fed3

Please sign in to comment.