parent
3468d7827d
commit
a2f42e4d6d
@ -0,0 +1,5 @@ |
||||
import './loginHandler'; |
||||
import './settings'; |
||||
import './testConnection'; |
||||
import './syncUsers'; |
||||
import './sync'; |
||||
@ -1,60 +1,78 @@ |
||||
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} |
||||
]; |
||||
const groupFilterQuery = [ |
||||
{_id: 'LDAP_Enable', value: true}, |
||||
{_id: 'LDAP_Group_Filter_Enable', value: true} |
||||
]; |
||||
|
||||
this.add('LDAP_Enable', false, { type: 'boolean', public: true }); |
||||
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Host', '', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Port', '389', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Connect_Timeout', 600000, {type: 'int', enableQuery}); |
||||
this.add('LDAP_Idle_Timeout', 600000, {type: 'int', enableQuery}); |
||||
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], 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 }); |
||||
this.add('LDAP_Use_Custom_Domain_Search', false, { type: 'boolean', 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 }); |
||||
RocketChat.settings.addGroup('LDAP', function() { |
||||
const enableQuery = {_id: 'LDAP_Enable', value: true}; |
||||
const enableAuthentication = [ |
||||
enableQuery, |
||||
{_id: 'LDAP_Authentication', value: true} |
||||
]; |
||||
const enableTLSQuery = [ |
||||
enableQuery, |
||||
{_id: 'LDAP_Encryption', value: {$in: ['tls', 'ssl']}} |
||||
]; |
||||
const syncDataQuery = [ |
||||
enableQuery, |
||||
{_id: 'LDAP_Sync_User_Data', value: true} |
||||
]; |
||||
const groupFilterQuery = [ |
||||
enableQuery, |
||||
{_id: 'LDAP_Group_Filter_Enable', value: true} |
||||
]; |
||||
const backgroundSyncQuery = [ |
||||
enableQuery, |
||||
{_id: 'LDAP_Background_Sync', value: true} |
||||
]; |
||||
|
||||
this.add('LDAP_Enable', false, { type: 'boolean', public: true }); |
||||
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Host', '', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Port', '389', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], 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_BaseDN', '', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Test_Connection', 'ldap_test_connection', { type: 'action', actionText: 'Test_Connection' }); |
||||
|
||||
this.section('Authentication', function() { |
||||
this.add('LDAP_Authentication', false, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Authentication_UserDN', '', { type: 'string', enableQuery: enableAuthentication }); |
||||
this.add('LDAP_Authentication_Password', '', { type: 'password', enableQuery: enableAuthentication }); |
||||
}); |
||||
|
||||
this.section('Timeouts', function() { |
||||
this.add('LDAP_Timeout', 60000, {type: 'int', enableQuery}); |
||||
this.add('LDAP_Connect_Timeout', 1000, {type: 'int', enableQuery}); |
||||
this.add('LDAP_Idle_Timeout', 1000, {type: 'int', enableQuery}); |
||||
}); |
||||
|
||||
this.section('User Search', function() { |
||||
this.add('LDAP_User_Search_Filter', '(objectclass=*)', { type: 'string', enableQuery }); |
||||
this.add('LDAP_User_Search_Scope', 'sub', { type: 'string', enableQuery }); |
||||
this.add('LDAP_User_Search_Field', 'sAMAccountName', { type: 'string', enableQuery }); |
||||
}); |
||||
|
||||
this.section('User Search (Group Validation)', function() { |
||||
this.add('LDAP_Group_Filter_Enable', false, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Group_Filter_ObjectClass', 'groupOfUniqueNames', { type: 'string', enableQuery: groupFilterQuery }); |
||||
this.add('LDAP_Group_Filter_Group_Id_Attribute', 'cn', { type: 'string', enableQuery: groupFilterQuery }); |
||||
this.add('LDAP_Group_Filter_Group_Member_Attribute', 'uniqueMember', { type: 'string', enableQuery: groupFilterQuery }); |
||||
this.add('LDAP_Group_Filter_Group_Member_Format', 'uniqueMember', { type: 'string', enableQuery: groupFilterQuery }); |
||||
this.add('LDAP_Group_Filter_Group_Name', 'ROCKET_CHAT', { type: 'string', enableQuery: groupFilterQuery }); |
||||
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.section('Sync / Import', function() { |
||||
this.add('LDAP_Username_Field', 'sAMAccountName', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Unique_Identifier_Field', 'objectGUID,ibm-entryUUID,GUID,dominoUNID,nsuniqueId,uidNumber', { type: 'string', enableQuery }); |
||||
this.add('LDAP_Sync_User_Data', false, { type: 'boolean', 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 }); |
||||
this.add('LDAP_Merge_Existing_Users', false, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Import_Users', false, { type: 'boolean', enableQuery: syncDataQuery }); |
||||
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' }); |
||||
|
||||
this.add('LDAP_Sync_User_Data', false, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Sync_User_Data_FieldMap', '{"cn":"name", "mail":"email"}', { type: 'string', enableQuery: syncDataQuery }); |
||||
this.add('LDAP_Sync_User_Avatar', true, { type: 'boolean', enableQuery }); |
||||
|
||||
this.add('LDAP_Background_Sync', false, { type: 'boolean', enableQuery }); |
||||
this.add('LDAP_Background_Sync_Interval', 'Every 24 hours', { type: 'string', enableQuery: backgroundSyncQuery }); |
||||
this.add('LDAP_Background_Sync_Import_New_Users', true, { type: 'boolean', enableQuery: backgroundSyncQuery }); |
||||
this.add('LDAP_Background_Sync_Keep_Existant_Users_Updated', true, { type: 'boolean', enableQuery: backgroundSyncQuery }); |
||||
|
||||
this.add('LDAP_Sync_Now', 'ldap_sync_now', { type: 'action', actionText: 'Execute_Synchronization_Now' }); |
||||
}); |
||||
}); |
||||
|
||||
@ -0,0 +1,136 @@ |
||||
RocketChat.Migrations.add({ |
||||
version: 102, |
||||
up() { |
||||
if (!RocketChat || !RocketChat.models || !RocketChat.models.Settings) { |
||||
return; |
||||
} |
||||
|
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Connect_Timeout', value: 600000 }, |
||||
{ $set: { value: 1000 } } |
||||
); |
||||
|
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Idle_Timeout', value: 600000 }, |
||||
{ $set: { value: 1000 } } |
||||
); |
||||
|
||||
const LDAP_Domain_Base = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Base' }); |
||||
if (LDAP_Domain_Base) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_BaseDN' }, |
||||
{ $set: { value: LDAP_Domain_Base.value } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Base' }); |
||||
|
||||
const LDAP_Domain_Search_User_ID = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_User_ID' }); |
||||
if (LDAP_Domain_Search_User_ID) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_User_Search_Field' }, |
||||
{ $set: { value: LDAP_Domain_Search_User_ID.value } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_User_ID' }); |
||||
|
||||
const LDAP_Use_Custom_Domain_Search = RocketChat.models.Settings.findOne({ _id: 'LDAP_Use_Custom_Domain_Search' }); |
||||
const LDAP_Custom_Domain_Search = RocketChat.models.Settings.findOne({ _id: 'LDAP_Custom_Domain_Search' }); |
||||
|
||||
const LDAP_Domain_Search_User = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_User' }); |
||||
const LDAP_Domain_Search_Password = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_Password' }); |
||||
const LDAP_Domain_Search_Filter = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_Filter' }); |
||||
|
||||
const LDAP_Domain_Search_Object_Class = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_Object_Class' }); |
||||
const LDAP_Domain_Search_Object_Category = RocketChat.models.Settings.findOne({ _id: 'LDAP_Domain_Search_Object_Category' }); |
||||
|
||||
if (LDAP_Use_Custom_Domain_Search) { |
||||
if (LDAP_Use_Custom_Domain_Search.value === true) { |
||||
let Custom_Domain_Search; |
||||
try { |
||||
Custom_Domain_Search = JSON.parse(LDAP_Custom_Domain_Search.value); |
||||
} catch (error) { |
||||
throw new Error('Invalid Custom Domain Search JSON'); |
||||
} |
||||
|
||||
LDAP_Domain_Search_User.value = Custom_Domain_Search.userDN || ''; |
||||
LDAP_Domain_Search_Password.value = Custom_Domain_Search.password || ''; |
||||
LDAP_Domain_Search_Filter.value = Custom_Domain_Search.filter; |
||||
} else { |
||||
const filter = []; |
||||
|
||||
if (LDAP_Domain_Search_Object_Category.value !== '') { |
||||
filter.push(`(objectCategory=${ LDAP_Domain_Search_Object_Category.value })`); |
||||
} |
||||
|
||||
if (LDAP_Domain_Search_Object_Class.value !== '') { |
||||
filter.push(`(objectclass=${ LDAP_Domain_Search_Object_Class.value })`); |
||||
} |
||||
|
||||
if (LDAP_Domain_Search_Filter.value !== '') { |
||||
filter.push(`(${ LDAP_Domain_Search_Filter.value })`); |
||||
} |
||||
|
||||
if (filter.length === 1) { |
||||
LDAP_Domain_Search_Filter.value = filter[0]; |
||||
} else if (filter.length > 1) { |
||||
LDAP_Domain_Search_Filter.value = `(&${ filter.join('') })`; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (LDAP_Domain_Search_Filter && LDAP_Domain_Search_Filter.value) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_User_Search_Filter' }, |
||||
{ $set: { value: LDAP_Domain_Search_Filter.value } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_Filter' }); |
||||
|
||||
if (LDAP_Domain_Search_User && LDAP_Domain_Search_User.value) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Authentication_UserDN' }, |
||||
{ $set: { value: LDAP_Domain_Search_User.value } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_User' }); |
||||
|
||||
|
||||
if (LDAP_Domain_Search_Password && LDAP_Domain_Search_Password.value) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Authentication_Password' }, |
||||
{ $set: { value: LDAP_Domain_Search_Password.value } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_Password' }); |
||||
|
||||
if (LDAP_Domain_Search_User && LDAP_Domain_Search_User.value && LDAP_Domain_Search_Password && LDAP_Domain_Search_Password.value) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Authentication' }, |
||||
{ $set: { value: true } } |
||||
); |
||||
} |
||||
|
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Use_Custom_Domain_Search' }); |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Custom_Domain_Search' }); |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_Object_Class' }); |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Domain_Search_Object_Category' }); |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Sync_Users' }); //Button
|
||||
|
||||
const LDAP_Sync_User_Data = RocketChat.models.Settings.findOne({ _id: 'LDAP_Sync_User_Data' }); |
||||
if (LDAP_Sync_User_Data && LDAP_Sync_User_Data.value) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Background_Sync' }, |
||||
{ $set: { value: true } } |
||||
); |
||||
} |
||||
|
||||
const LDAP_Import_Users = RocketChat.models.Settings.findOne({ _id: 'LDAP_Import_Users' }); |
||||
if (LDAP_Import_Users && LDAP_Import_Users.value === false) { |
||||
RocketChat.models.Settings.update( |
||||
{ _id: 'LDAP_Background_Sync_Import_New_Users' }, |
||||
{ $set: { value: false } } |
||||
); |
||||
} |
||||
RocketChat.models.Settings.remove({ _id: 'LDAP_Import_Users' }); |
||||
} |
||||
}); |
||||
Loading…
Reference in new issue