Comments
-
Greg Hurrell
Thinking about it more, I definitely like the idea of doing it on a successful login.
We are in no hurry to rush this particular migration, so it doesn't matter how long people take to actually log in and update their hash.
The basic plan would be this:
- Add a hash-type column to the users table.
- When a user logs in successfully using the old hash, at that point we store a new hash and update the hash-type as well; we can do this because we have the plaintext password at that point.
Pretty simple really.
As for how to do the bcrypt digesting, there is a bcrypt-ruby gem:
But I think you can make bcrypt digests using the OpenSSL module which is in the standard library. Just checking that out now.
-
Greg Hurrell
Looks like this isn't exposed in the standard library module, at least as far as I can tell.
The source code for the bcrypt-ruby gem calls into the OpenSSH library from inside a C extension:
-
Greg Hurrell
The thing about the bcrypt-ruby gem that gives me the creeps is this:
$ irb -r bcrypt >> pass = BCrypt::Password.create('secret') => "$2a$10$kfrJ4wG9T1N96lemyy8pX.OIoIIrYpxZWawfl/6FLuaDlKc8Mag8i" >> pass == 'guess' => false >> pass == 'secret' => true >> 'secret' == pass => false
Something about overriding the
==
operator in such a way thata == b
butb != a
just makes me feel queasy (I understand why you can't makeb == a
work, seeing as this is by definition a one-way hash function and you can't therefore make a usefulto_s
method on it, but to me that's an indication that you shouldn't be overriding the==
operator in the first place). -
Greg Hurrell
For shits and giggles, check out the bickering on this HN thread about the ups/downs of taking a "salt & pepper" approach.
-
Greg Hurrell
There are some things I don't particularly like about the design of the bcrypt-ruby gem. An in-standard-library alternative is PBKDF2. Arguably not as secure, but still much more secure than a normal crypto hash (ie. one not designed for password hashing).
-
Greg Hurrell
Status changed:
- From: new
- To: closed
Add a comment
Comments are now closed for this issue.