Upgrade devise, devise-two-factor, and attr_encrypted
Devise (3.5.4 => 4.1.1) Changelog: https://github.com/plataformatec/devise/blob/master/CHANGELOG.md
devise-two-factor (2.0.1 => 3.0.0) Changelog: https://github.com/tinfoil/devise-two-factor/blob/master/CHANGELOG.md
attr_encrypted (1.3.4 => 3.0.1) Changelog: https://github.com/attr-encrypted/attr_encrypted/blob/master/CHANGELOG.md
Devise 4 includes support for Rails 5, working towards #14286 (moved). devise-async doesn't support Devise 4.0 and in 4.1 the bug that was blocking using Devise's built-in ActiveJob integration was fixed. So devise-async is removed. devise-two-factor 3.0.0 is required for Devise 4 support.
attr_encrypted and encryptor are optional but recommended upgrades for devise-two-factor 3.0.0. The mode and algorithm will need to be changed in order to update to attr_encrypted 4.x in the future.
cc: @rspeicher
Merge request reports
Activity
Added 1 commit:
- bf26c720 - Upgrade attr_encrypted and encryptor
mentioned in issue #14286 (moved)
Reassigned to @rspeicher
pokes @rspeicher
11 11 format: { with: /\A[a-zA-Z0-9_]+\z/, 12 12 message: "can contain only letters, digits and '_'." } 13 13 14 attr_encrypted :value, mode: :per_attribute_iv_and_salt, key: Gitlab::Application.secrets.db_key_base 14 attr_encrypted :value, 15 mode: :per_attribute_iv_and_salt, 16 key: Gitlab::Application.secrets.db_key_base, 17 algorithm: 'aes-256-cbc' @connorshea What's the reasoning for using this algorithm over the default
aes-256-gcm
?aes-256-cbc was the previous default and used by devise-two-factor to encrypt existing 2FA data. If we change to aes-256-gcm, the user would have to take the app offline, and decrypt then re-encrypt all encrypted info using the new cipher. Either that or all 2FA codes and any other encrypted data become non-decryptable.
- config/initializers/devise_async.rb deleted 100644 → 0
1 Devise::Async.backend = :sidekiq That issue was fixed by Devise 4.1.0, see https://github.com/plataformatec/devise/issues/3550
23 23 end 24 24 25 25 it 'fails to decrypt if iv is incorrect' do 26 subject.encrypted_value_iv = nil 26 subject.encrypted_value_iv = SecureRandom.hex 11 11 format: { with: /\A[a-zA-Z0-9_]+\z/, 12 12 message: "can contain only letters, digits and '_'." } 13 13 14 attr_encrypted :value, mode: :per_attribute_iv_and_salt, key: Gitlab::Application.secrets.db_key_base 14 attr_encrypted :value, 15 mode: :per_attribute_iv_and_salt, 12 12 post(:create, user: { login: 'invalid', password: 'invalid' }) 13 13 14 14 expect(response) 15 .to set_flash.now[:alert].to /Invalid login or password/ 15 .to set_flash.now[:alert].to /Invalid Login or password/ I'm already on it :) Relevant issue:
https://github.com/plataformatec/devise/issues/4095
There's nothing we can do from our side that'll fix this since they humanize the keys using Ruby (https://github.com/plataformatec/devise/pull/4014/files#diff-c1be825bdb5f3160081e41432f83d0d7R106). We could monkeypatch it, but I'd prefer to fix it upstream instead.
@rspeicher I don't think the grammar issue warrants blocking this MR, do my comments address all your concerns?
Ok, I tried this locally with an account that already had 2FA enabled and both the OTP and the backup codes worked without issue, so I think we're good.
Thanks @connorshea
mentioned in commit 7d33fba7