devise-argon2 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7542aed226ac27c831a5f6acdbb6011fe8b6632e83a60902341c4f44bad38b27
4
- data.tar.gz: 63891613bb7343641df64221d56533f646543c8eb0c8b3f9fe32186a4f4c46df
3
+ metadata.gz: b13e34bfd72f10cc708b067b1153dc9cb8b3aa9a904e47bc25c8d2a75acc7f62
4
+ data.tar.gz: 8f925ef0029619168d1d01bef19adb9769b503c8b68bc1b94997f222aa86c989
5
5
  SHA512:
6
- metadata.gz: 958d4df9feceff3bb4b28c85eed86f0072cd9914ba7f00cfdc26379def7af570647812fb72e14303b02ad435d4e8450d6cbc63b76a7b23380de1218828fac365
7
- data.tar.gz: f639d484fe68ff7d39df88511a06c15b4518ddce58cf02057d39f99524aa5942af83427bb2268f66fe2facd36c30cb72477782f903d2d17e1dfd8f7e644a4fc7
6
+ metadata.gz: 512b621099a74b85a1dd79ca5f9108cb9cf8105fd499b14c78c4d2fb6e1de2c8edbb8eabc3be94a5d783ef2f2dcb5d0a063bdeb9ddf8c1ffdbc27a3368c61027
7
+ data.tar.gz: 25e032a128c02cb60012f3e20654e049a84cec7cbebbcbbfe0f1588f71d6b63a9158b7b5ec1ceeb0c77b4e103c89f9fca9d4d38e0c21029228e06e03c7483356
@@ -7,68 +7,36 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
11
- rails-version: ['~> 6.1', '~> 7.0', '~> 7.1', '~> 7.2', '8.0.0.beta1']
10
+ ruby-version: ['3.1', '3.2', '3.3', '3.4']
11
+ rails-version: ['~> 7.2', '~> 8.0', '~> 8.1']
12
12
  argon2-version: ['2.2', '2.3']
13
+ devise-version: ['~> 4.9', 'main']
13
14
  orm:
14
15
  - adapter: active_record
15
16
  - adapter: mongoid
16
- mongoid-version: 9.0.2
17
+ mongoid-version: 9.0.3
17
18
  - adapter: mongoid
18
- mongoid-version: 8.1.6
19
- - adapter: mongoid
20
- mongoid-version: 8.0.8
21
- - adapter: mongoid
22
- mongoid-version: 7.5.4
19
+ mongoid-version: 8.1.7
23
20
  exclude:
24
- - rails-version: '~> 7.2'
25
- ruby-version: '2.7'
26
- - rails-version: '~> 7.2'
27
- ruby-version: '3.0'
28
- - rails-version: '8.0.0.beta1'
29
- ruby-version: '2.7'
30
- - rails-version: '8.0.0.beta1'
31
- ruby-version: '3.0'
32
- - rails-version: '8.0.0.beta1'
21
+ - rails-version: '~> 8.1'
22
+ ruby-version: '3.1'
23
+ - rails-version: '~> 8.0'
33
24
  ruby-version: '3.1'
34
25
  - orm:
35
26
  adapter: mongoid
36
- rails-version: '8.0.0.beta1'
37
- - orm:
38
- adapter: mongoid
39
- mongoid-version: 8.0.8
40
- ruby-version: '3.3'
41
- - orm:
42
- adapter: mongoid
43
- mongoid-version: 8.0.8
44
- ruby-version: '3.2'
45
- - orm:
46
- adapter: mongoid
47
- mongoid-version: 7.5.4
48
- ruby-version: '3.3'
49
- - orm:
50
- adapter: mongoid
51
- mongoid-version: 7.5.4
52
- ruby-version: '3.2'
53
- - orm:
54
- adapter: mongoid
55
- mongoid-version: 8.0.8
56
- rails-version: '~> 7.2'
57
- - orm:
58
- adapter: mongoid
59
- mongoid-version: 7.5.4
60
- rails-version: '~> 7.2'
61
- - orm:
62
- adapter: mongoid
63
- mongoid-version: 7.5.4
64
- rails-version: '~> 7.1'
27
+ rails-version: '~> 8.1'
65
28
  env:
66
- RAILS_VERSION: ${{ matrix.rails-version || '~> 7.0'}}
29
+ RAILS_VERSION: ${{ matrix.rails-version || '~> 8.0'}}
67
30
  MONGOID_VERSION: ${{ matrix.orm.mongoid-version || '8.1.6'}}
68
31
  ORM: ${{ matrix.orm.adapter }}
69
32
  ARGON2_VERSION: ${{ matrix.argon2-version }}
70
33
  DEVISE_VERSION: ${{ matrix.devise-version || '~> 4.9' }}
71
34
  steps:
35
+ - name: Login to Docker Hub
36
+ uses: docker/login-action@v3
37
+ with:
38
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
39
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
72
40
  - uses: actions/checkout@v4
73
41
  - name: Set up Ruby ${{ matrix.ruby-version }}
74
42
  uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -18,4 +18,5 @@ spec/rails_app/db/test.sqlite3*
18
18
  test/tmp
19
19
  test/version_tmp
20
20
  tmp
21
- .ruby-gemset
21
+ .ruby-gemset
22
+ .idea
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [2.0.3] - 2025-03-23
6
+
7
+ ### Fixed
8
+ - Fix bug where users would not be migrated from v1 when setting a password manually. (#21)
9
+
5
10
  ## [2.0.2] - 2024-09-30
6
11
 
7
12
  ### Changed
data/Gemfile CHANGED
@@ -5,16 +5,17 @@ gemspec
5
5
  gem 'rspec'
6
6
  gem 'simplecov'
7
7
  gem 'activerecord'
8
- gem 'rails', ENV['RAILS_VERSION'] || '~> 7.0'
8
+ gem 'rails', ENV['RAILS_VERSION'] || '~> 8.0'
9
9
  gem 'argon2', ENV['ARGON2_VERSION'] || '~> 2.3'
10
- gem 'devise', ENV['DEVISE_VERSION'] || '~> 4.9'
10
+
11
+ if ENV['DEVISE_VERSION'] == 'main'
12
+ gem 'devise', github: 'heartcombo/devise'
13
+ else
14
+ gem 'devise', ENV['DEVISE_VERSION'] || '~> 4.9'
15
+ end
11
16
 
12
17
  if ENV['ORM'] == 'mongoid'
13
18
  gem 'mongoid', ENV['MONGOID_VERSION'] || '~> 7.5'
14
19
  end
15
20
 
16
- if ENV['RAILS_VERSION'] == '8.0.0.beta1'
17
- gem 'sqlite3', '~> 2.1'
18
- else
19
- gem 'sqlite3', '~> 1.6', '>= 1.6.6'
20
- end
21
+ gem 'sqlite3', '~> 2.8'
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'devise', '~> 4.0'
21
+ gem.add_dependency 'devise', '>= 4.0'
22
22
  gem.add_dependency 'argon2', '~> 2.1'
23
23
 
24
24
 
@@ -38,6 +38,11 @@ module Devise
38
38
  is_valid
39
39
  end
40
40
 
41
+ def password=(new_password)
42
+ self.password_salt = nil if migrate_hash_from_devise_argon2_v1?
43
+ super
44
+ end
45
+
41
46
  protected
42
47
 
43
48
  def password_digest(password)
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Argon2
3
- ARGON2_VERSION = '2.0.2'
3
+ ARGON2_VERSION = '2.0.4'
4
4
  end
5
5
  end
@@ -302,4 +302,38 @@ describe Devise::Models::Argon2 do
302
302
  )
303
303
  end
304
304
  end
305
+
306
+ describe 'password reset' do
307
+ NEW_PASSWORD = 'new password'
308
+
309
+ shared_examples 'ways of resetting the password' do
310
+ it 'can be done via password_reset' do
311
+ user.reset_password(NEW_PASSWORD, NEW_PASSWORD)
312
+ expect(user.valid_password?(NEW_PASSWORD)).to be true
313
+ end
314
+
315
+ it 'can be done via password=' do
316
+ user.password = NEW_PASSWORD
317
+ expect(user.valid_password?(NEW_PASSWORD)).to be true
318
+ end
319
+ end
320
+
321
+ context 'encrypted_password is hashed with the current version of devise-argon2' do
322
+ include_examples 'ways of resetting the password'
323
+ end
324
+
325
+ context 'encrypted_password is hashed with version 1 of devise-argon2' do
326
+ let(:user) { OldUser.new(password: CORRECT_PASSWORD) }
327
+
328
+ before do
329
+ Devise.argon2_options.merge!({ migrate_from_devise_argon2_v1: true })
330
+ user.password_salt = 'devise-argon2 v1 salt'
331
+ user.encrypted_password = ::Argon2::Password.create(
332
+ "#{CORRECT_PASSWORD}#{user.password_salt}#{Devise.pepper}"
333
+ )
334
+ end
335
+
336
+ include_examples 'ways of resetting the password'
337
+ end
338
+ end
305
339
  end
@@ -1,3 +1,3 @@
1
1
  class OldUser < ActiveRecord::Base
2
- devise :database_authenticatable, :argon2
2
+ devise :database_authenticatable, :recoverable, :argon2
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
- devise :database_authenticatable, :argon2
2
+ devise :database_authenticatable, :recoverable, :argon2
3
3
  end
@@ -1,7 +1,7 @@
1
1
  class OldUser
2
2
  include Mongoid::Document
3
3
 
4
- devise :database_authenticatable, :argon2
4
+ devise :database_authenticatable, :recoverable, :argon2
5
5
 
6
6
  field :email, type: String, default: ""
7
7
  field :encrypted_password, type: String, default: ""
@@ -1,7 +1,7 @@
1
1
  class User
2
2
  include Mongoid::Document
3
3
 
4
- devise :database_authenticatable, :argon2
4
+ devise :database_authenticatable, :recoverable, :argon2
5
5
 
6
6
  field :email, type: String, default: ""
7
7
  field :encrypted_password, type: String, default: ""
@@ -0,0 +1,6 @@
1
+ class AddRecoverableFieldsToUsers < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :users, :reset_password_token, :string
4
+ add_column :users, :reset_password_sent_at, :datetime
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddRecoverableFieldsToOldUsers < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :old_users, :reset_password_token, :string
4
+ add_column :old_users, :reset_password_sent_at, :datetime
5
+ end
6
+ end
@@ -10,13 +10,15 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2023_10_04_084147) do
13
+ ActiveRecord::Schema.define(version: 2025_03_19_085738) do
14
14
  create_table "old_users", force: :cascade do |t|
15
15
  t.string "email", default: "", null: false
16
16
  t.string "encrypted_password", default: "", null: false
17
17
  t.string "password_salt"
18
18
  t.datetime "created_at", null: false
19
19
  t.datetime "updated_at", null: false
20
+ t.string "reset_password_token"
21
+ t.datetime "reset_password_sent_at"
20
22
  t.index ["email"], name: "index_old_users_on_email", unique: true
21
23
  end
22
24
 
@@ -25,7 +27,8 @@ ActiveRecord::Schema.define(version: 2023_10_04_084147) do
25
27
  t.string "encrypted_password", default: "", null: false
26
28
  t.datetime "created_at", null: false
27
29
  t.datetime "updated_at", null: false
30
+ t.string "reset_password_token"
31
+ t.datetime "reset_password_sent_at"
28
32
  t.index ["email"], name: "index_users_on_email", unique: true
29
33
  end
30
-
31
34
  end
metadata CHANGED
@@ -1,28 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-argon2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamas Erdos
8
8
  - Moritz Höppner
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-09-30 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: devise
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - "~>"
17
+ - - ">="
19
18
  - !ruby/object:Gem::Version
20
19
  version: '4.0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - "~>"
24
+ - - ">="
26
25
  - !ruby/object:Gem::Version
27
26
  version: '4.0'
28
27
  - !ruby/object:Gem::Dependency
@@ -81,6 +80,8 @@ files:
81
80
  - spec/rails_app/config/routes.rb
82
81
  - spec/rails_app/db/migrate/20230617201921_devise_create_users.rb
83
82
  - spec/rails_app/db/migrate/20231004084147_devise_create_old_users.rb
83
+ - spec/rails_app/db/migrate/20250319085725_add_recoverable_fields_to_users.rb
84
+ - spec/rails_app/db/migrate/20250319085738_add_recoverable_fields_to_old_users.rb
84
85
  - spec/rails_app/db/schema.rb
85
86
  - spec/spec_helper.rb
86
87
  homepage: https://github.com/erdostom/devise-argon2
@@ -103,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.4.22
107
- signing_key:
107
+ rubygems_version: 3.6.9
108
108
  specification_version: 4
109
109
  summary: Enables Devise to hash passwords with Argon2id
110
110
  test_files:
@@ -131,5 +131,7 @@ test_files:
131
131
  - spec/rails_app/config/routes.rb
132
132
  - spec/rails_app/db/migrate/20230617201921_devise_create_users.rb
133
133
  - spec/rails_app/db/migrate/20231004084147_devise_create_old_users.rb
134
+ - spec/rails_app/db/migrate/20250319085725_add_recoverable_fields_to_users.rb
135
+ - spec/rails_app/db/migrate/20250319085738_add_recoverable_fields_to_old_users.rb
134
136
  - spec/rails_app/db/schema.rb
135
137
  - spec/spec_helper.rb