Skip to content

Commit 7d33a57

Browse files
committed
Add Argon support
1 parent 91d6a00 commit 7d33a57

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

plugin.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# name: discourse-migratepassword
22
# about: enable alternative password hashes
3-
# version: 0.71
4-
# authors: Jens Maier and Michael@discoursehosting.com
3+
# version: 0.8
4+
# authors: Jens Maier and michael@communiteq.com
55
# url: https://github.com/discoursehosting/discourse-migratepassword
66

77
# Usage:
@@ -25,6 +25,10 @@
2525
gem 'bcrypt', '3.1.3'
2626
gem 'unix-crypt', '1.3.0', :require_name => 'unix_crypt'
2727

28+
gem 'ffi', '1.15.5', require: false
29+
gem 'ffi-compiler', '1.0.1', require: false
30+
gem 'argon2', '2.1.1'
31+
2832
enabled_site_setting :migratepassword_enabled
2933

3034
require 'digest'
@@ -237,7 +241,17 @@ def self.check_all(password, crypted_pass)
237241
AlternativePassword::check_joomla_3_2(password, crypted_pass) ||
238242
AlternativePassword::check_q2a(password, crypted_pass) ||
239243
AlternativePassword::check_drupal7(password, crypted_pass) ||
240-
AlternativePassword::check_devise(password, crypted_pass)
244+
AlternativePassword::check_devise(password, crypted_pass) ||
245+
AlternativePassword::check_argon(password, crypted_pass)
246+
end
247+
248+
def self.check_argon(password, crypted_pass)
249+
begin
250+
return false unless crypted_pass[0..9] == '$argon2id$'
251+
return Argon2::Password.verify_password(password, crypted_pass)
252+
rescue
253+
false
254+
end
241255
end
242256

243257
def self.check_devise(password, crypted_pass)

0 commit comments

Comments
 (0)