diff --git a/app/models/user.rb b/app/models/user.rb index b2235bff456e443d412a084cb94a0683098475ad..1590a5c2149e0e1f751435fd785013613aca803a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2333,9 +2333,7 @@ def check_username_format end def check_password_weakness - if Feature.enabled?(:block_weak_passwords) && - password.present? && - Security::WeakPasswords.weak_for_user?(password, self) + if password.present? && Security::WeakPasswords.weak_for_user?(password, self) errors.add(:password, _('must not contain commonly used combinations of words and letters')) end end diff --git a/config/feature_flags/development/block_weak_passwords.yml b/config/feature_flags/development/block_weak_passwords.yml deleted file mode 100644 index aaa8c2cac387d0d44711d147c353e6c5b6eb1eeb..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/block_weak_passwords.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: block_weak_passwords -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/86310 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/363445 -milestone: '15.4' -type: development -group: group::authentication and authorization -default_enabled: false diff --git a/doc/user/profile/user_passwords.md b/doc/user/profile/user_passwords.md index b8dbdcdd956d74ec7ebf536df370a8c0eec6cff5..9c1ba8852d236e4205aaf7f5be0c6a58ee013e7c 100644 --- a/doc/user/profile/user_passwords.md +++ b/doc/user/profile/user_passwords.md @@ -61,12 +61,8 @@ Self-managed installations can configure the following additional password requi ## Block weak passwords > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/23610) in GitLab 15.4 [with a flag](../../administration/feature_flags.md) named `block_weak_passwords`, weak passwords aren't accepted. Disabled by default on self-managed. -> - [Enabled](https://gitlab.com/gitlab-org/gitlab/-/issues/363445) on GitLab.com. - -FLAG: -On self-managed GitLab, by default blocking weak passwords is not available. To make it available, ask an administrator -to [enable the feature flag](../../administration/feature_flags.md) named `block_weak_passwords`. On GitLab.com, this -feature is available but can be configured by GitLab.com administrators only. +> - [Enabled](https://gitlab.com/gitlab-org/gitlab/-/issues/363445) on GitLab.com in GitLab 15.6. +> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/363445) and enabled on self-managed in GitLab 15.7. Feature flag `block_weak_passwords` removed. GitLab disallows weak passwords. Your password is considered weak when it: diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 8775f68a5dea8205ad9ecca9c84ac8ce3f377dfa..bc07df62853375bdc1669976d30071d686f4efb3 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -486,34 +486,22 @@ subject { post(:create, params: new_user_params) } - context 'when block_weak_passwords is enabled (default)' do - it 'renders the form with errors' do - expect { subject }.not_to change(User, :count) + it 'renders the form with errors' do + expect { subject }.not_to change(User, :count) - expect(controller.current_user).to be_nil - expect(response).to render_template(:new) - expect(response.body).to include(_('Password must not contain commonly used combinations of words and letters')) - end - - it 'tracks the error' do - subject - expect_snowplow_event( - category: 'Gitlab::Tracking::Helpers::WeakPasswordErrorEvent', - action: 'track_weak_password_error', - controller: 'RegistrationsController', - method: 'create' - ) - end + expect(controller.current_user).to be_nil + expect(response).to render_template(:new) + expect(response.body).to include(_('Password must not contain commonly used combinations of words and letters')) end - context 'when block_weak_passwords is disabled' do - before do - stub_feature_flags(block_weak_passwords: false) - end - - it 'permits weak passwords' do - expect { subject }.to change(User, :count).by(1) - end + it 'tracks the error' do + subject + expect_snowplow_event( + category: 'Gitlab::Tracking::Helpers::WeakPasswordErrorEvent', + action: 'track_weak_password_error', + controller: 'RegistrationsController', + method: 'create' + ) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index fdeb98f52aea9f29d319d358a0bfb3d3594d9524..13ca9e3c81fc70dab3f306c5203cdb496b129da4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -345,52 +345,33 @@ context 'check_password_weakness' do let(:weak_password) { "qwertyuiop" } - context 'when feature flag is disabled' do - before do - stub_feature_flags(block_weak_passwords: false) - end - - it 'does not add an error when password is weak' do - expect(Security::WeakPasswords).not_to receive(:weak_for_user?) - - user.password = weak_password - expect(user).to be_valid - end + it 'checks for password weakness when password changes' do + expect(Security::WeakPasswords).to receive(:weak_for_user?) + .with(weak_password, user).and_call_original + user.password = weak_password + expect(user).not_to be_valid end - context 'when feature flag is enabled' do - before do - stub_feature_flags(block_weak_passwords: true) - end - - it 'checks for password weakness when password changes' do - expect(Security::WeakPasswords).to receive(:weak_for_user?) - .with(weak_password, user).and_call_original - user.password = weak_password - expect(user).not_to be_valid - end - - it 'adds an error when password is weak' do - user.password = weak_password - expect(user).not_to be_valid - expect(user.errors).to be_of_kind(:password, 'must not contain commonly used combinations of words and letters') - end + it 'adds an error when password is weak' do + user.password = weak_password + expect(user).not_to be_valid + expect(user.errors).to be_of_kind(:password, 'must not contain commonly used combinations of words and letters') + end - it 'is valid when password is not weak' do - user.password = ::User.random_password - expect(user).to be_valid - end + it 'is valid when password is not weak' do + user.password = ::User.random_password + expect(user).to be_valid + end - it 'is valid when weak password was already set' do - user = build(:user, password: weak_password) - user.save!(validate: false) + it 'is valid when weak password was already set' do + user = build(:user, password: weak_password) + user.save!(validate: false) - expect(Security::WeakPasswords).not_to receive(:weak_for_user?) + expect(Security::WeakPasswords).not_to receive(:weak_for_user?) - # Change an unrelated value - user.name = "Example McExampleFace" - expect(user).to be_valid - end + # Change an unrelated value + user.name = "Example McExampleFace" + expect(user).to be_valid end end end