Skip to content

Commit

Permalink
Merge pull request #9 from StackableRegiments/master
Browse files Browse the repository at this point in the history
This modification enables phpass in both its $P$ and $H$ signature forms
  • Loading branch information
communiteq committed Mar 7, 2018
2 parents 614d819 + 16b799a commit 7839f53
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugin.rb
@@ -1,10 +1,8 @@
# name: discourse-migratepassword
# about: enable alternative password hashes
# version: 0.7
# version: 0.71
# authors: Jens Maier and Michael@discoursehosting.com
# url: https://github.com/discoursehosting/discourse-migratepassword

# uses phpass-ruby https://github.com/uu59/phpass-ruby

# Usage:
# When migrating, store a custom field with the user containing the crypted password
Expand All @@ -19,6 +17,8 @@
# for Joomla #{hash}:#{salt} md5(pass+salt)
# for Joomla 3.2 #{password} bcrypt(pass)

#This will be applied at runtime, as authentication is attempted. It does not apply at migration time.


gem 'bcrypt', '3.1.3'
gem 'unix-crypt', '1.3.0', :require_name => 'unix_crypt'
Expand All @@ -42,8 +42,10 @@ def hash(pw)
end

def check(pw, hash)
hash.gsub! /^\$H\$/, '$P$'
return false unless hash.start_with?('$P$')
crypt(pw, hash) == hash
crypted = crypt(pw,hash)
crypted == hash
end

private
Expand Down

0 comments on commit 7839f53

Please sign in to comment.