OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Disable user sync status by default
Oliver Günther3f53f156940e
diff --git a/config/constants/settings/definitions.rb b/config/constants/settings/definitions.rbindex a6087267884..61c1c4649ce 100644--- a/config/constants/settings/definitions.rb+++ b/config/constants/settings/definitions.rb@@ -533,7 +533,7 @@ Settings::Definition.define do# Update users' status through the synchronization jobadd :ldap_users_sync_status,format: :boolean,- default: true,+ default: false,writable: falseadd :ldap_tls_options,diff --git a/docs/system-admin-guide/authentication/ldap-authentication/README.md b/docs/system-admin-guide/authentication/ldap-authentication/README.mdindex 6cf1e107f3c..0970a860924 100644--- a/docs/system-admin-guide/authentication/ldap-authentication/README.md+++ b/docs/system-admin-guide/authentication/ldap-authentication/README.md@@ -141,14 +141,14 @@ Duplicates in the unique attributes (login, email) are not allowed and a secondBy default, OpenProject will synchronize user account details (name, e-mail, login) and their account status from the LDAP through a background worker job every 24 hours.-The user will be ensured to be active if it can be found in LDAP. Likewise, if the user cannot be found in the LDAP, its associated OpenProject account will be locked.+### **Enabling status synchronization**-### **Disabling status synchronization**+If you wish to synchronize the account status from the LDAP, you can enable status synchronization using the following configuration:-If you wish to synchronize account data from the LDAP, but not synchronize the status to the associated OpenProject account, you can do so with the following configuration variable:+- `ldap_users_sync_status: true`+- (or the ENV variable `OPENPROJECT_LDAP__USERS__SYNC__STATUS=true`)-- `ldap_users_sync_status: false`-- (or the ENV variable `OPENPROJECT_LDAP__USERS__SYNC__STATUS=false`)+The user will be ensured to be active if it can be found in LDAP. Likewise, if the user cannot be found in the LDAP, its associated OpenProject account will be locked.### Disabling the synchronization jobdiff --git a/spec/services/ldap/synchronize_users_service_integration_spec.rb b/spec/services/ldap/synchronize_users_service_integration_spec.rbindex aff1932c48f..0944ca47636 100644--- a/spec/services/ldap/synchronize_users_service_integration_spec.rb+++ b/spec/services/ldap/synchronize_users_service_integration_spec.rb@@ -23,56 +23,73 @@ describe Ldap::SynchronizeUsersService dolet!(:user_aa729) { create :user, login: 'aa729', firstname: 'Foobar', auth_source: }let!(:user_bb459) { create :user, login: 'bb459', firstname: 'Bla', auth_source: }- it 'updates the attributes of those users' do- subject+ context 'when user sync status is enabled',+ with_config: { ldap_users_sync_status: true } do- user_aa729.reload- user_bb459.reload+ it 'updates the attributes of those users' do+ subject- expect(user_aa729.firstname).to eq 'Alexandra'- expect(user_aa729.lastname).to eq 'Adams'- expect(user_aa729.mail).to eq '[email protected]'+ user_aa729.reload+ user_bb459.reload- expect(user_bb459.firstname).to eq 'Belle'- expect(user_bb459.lastname).to eq 'Baldwin'- expect(user_bb459.mail).to eq '[email protected]'- end+ expect(user_aa729.firstname).to eq 'Alexandra'+ expect(user_aa729.lastname).to eq 'Adams'+ expect(user_aa729.mail).to eq '[email protected]'- it 'updates one user if the other fails' do- allow(Users::UpdateService)- .to receive(:new)- .and_call_original+ expect(user_bb459.firstname).to eq 'Belle'+ expect(user_bb459.lastname).to eq 'Baldwin'+ expect(user_bb459.mail).to eq '[email protected]'+ end- allow(Users::UpdateService)- .to receive(:new)- .with(model: user_aa729, user: User.system)- .and_raise("Some bad error happening here")+ it 'updates one user if the other fails' do+ allow(Users::UpdateService)+ .to receive(:new)+ .and_call_original- subject+ allow(Users::UpdateService)+ .to receive(:new)+ .with(model: user_aa729, user: User.system)+ .and_raise("Some bad error happening here")- user_aa729.reload- user_bb459.reload+ subject- expect(user_aa729.firstname).to eq 'Foobar'- expect(user_aa729.lastname).to eq 'Bobbit'+ user_aa729.reload+ user_bb459.reload- expect(user_bb459.firstname).to eq 'Belle'- expect(user_bb459.lastname).to eq 'Baldwin'- expect(user_bb459.mail).to eq '[email protected]'- end+ expect(user_aa729.firstname).to eq 'Foobar'+ expect(user_aa729.lastname).to eq 'Bobbit'- it 'reactivates the account if it is locked' do- user_aa729.lock!+ expect(user_bb459.firstname).to eq 'Belle'+ expect(user_bb459.lastname).to eq 'Baldwin'+ expect(user_bb459.mail).to eq '[email protected]'+ end- expect(user_aa729.reload).to be_locked+ it 'reactivates the account if it is locked' do+ user_aa729.lock!- subject+ expect(user_aa729.reload).to be_locked- expect(user_aa729.reload).not_to be_locked- expect(user_aa729).to be_active+ subject++ expect(user_aa729.reload).not_to be_locked+ expect(user_aa729).to be_active+ end++ context 'with a user that is in another LDAP' do+ let(:auth_source2) { create :ldap_auth_source, name: 'Another LDAP' }+ let(:user_foo) { create :user, login: 'login', auth_source: auth_source2 }++ it 'does not touch that user' do+ expect(user_foo).to be_active++ subject++ expect(user_foo.reload).to be_active+ end+ endend- context 'when requesting not to sync users status',+ context 'when user sync status is disabled',with_config: { ldap_users_sync_status: false } doit 'does not reactivate the account if it is locked' douser_aa729.lock!@@ -117,15 +134,18 @@ describe Ldap::SynchronizeUsersService docontext 'with a user that is no longer in LDAP' dolet(:user_foo) { create :user, login: 'login', auth_source: }- it 'locks that user' do- expect(user_foo).to be_active+ context 'when user sync status is enabled',+ with_config: { ldap_users_sync_status: true } do+ it 'locks that user' do+ expect(user_foo).to be_active- subject+ subject- expect(user_foo.reload).to be_locked+ expect(user_foo.reload).to be_locked+ endend- context 'when requesting not to sync users status',+ context 'when user sync status is disabled',with_config: { ldap_users_sync_status: false } doit 'does not lock that user' doexpect(user_foo).to be_active@@ -137,16 +157,4 @@ describe Ldap::SynchronizeUsersService doendend- context 'with a user that is in another LDAP' do- let(:auth_source2) { create :ldap_auth_source, name: 'Another LDAP' }- let(:user_foo) { create :user, login: 'login', auth_source: auth_source2 }-- it 'does not touch that user' do- expect(user_foo).to be_active-- subject-- expect(user_foo.reload).to be_active- end- endend