News for hackers. Stuff that matters.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by roryokane on Saturday April 16, 2011 @08:32PM (#2455250)
As Anne_Ominous wrote in the comments, this solution needs salts to be truly secure. One reply to Anne links to a sentence in the bcrypt-ruby docs: "bcrypt-ruby automatically handles the storage and generation of these salts for you.". However, there's something I don't understand. Where are the salts stored? The linked article mentions only that the model needs a password_digest field. If the salt is stored alongside it, shouldn't we need a password_salt field too? And if the salt is stored in a separate database, isn't that inefficient and unscaleable?
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by createaccount94 on Saturday April 16, 2011 @09:59PM (#2455382)
>> hash = BCrypt::Password.create '123456'

=> "$2a$10$khoJWZR3hVA8Qcm3lW6sp.BQGOFKGo2xHCeH2YfDcQVRltEGCJe0S"

>> [hash.salt, hash.checksum]

=> ["$2a$10$khoJWZR3hVA8Qcm3lW6sp.", "BQGOFKGo2xHCeH2YfDcQVRltEGCJe0S"]

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by bodhi on Saturday April 16, 2011 @08:56PM (#2455291)
I believe, but I'd have to go check bcrypt to make sure, that the salt is stored as part of the digest.

Edit:

Actually, after minimal research, I see that salting the password is handled by the bcrypt ruby gem.

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by michaelfairley on Saturday April 16, 2011 @09:04PM (#2455306)
bcrypt stores the salt alongside the hash, so a single field is sufficient.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by zmanji on Saturday April 16, 2011 @07:48PM (#2455174)
Wouldn't this make gems like Devise irrelevant?
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by michaelfairley on Saturday April 16, 2011 @07:55PM (#2455187)
This still doesn't handle email verification, multiple roles, remember me tokens, and a slew of other features Devise offers.

This is really just some Rails sugar around bcrypt-ruby.

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by swaits on Saturday April 16, 2011 @08:11PM (#2455221)
Which wasn't that hard to use unsugared. This move also signals to the community that bcrypt is considered a best practice, important enough that it's included by default. Rails benefits from this.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by there on Saturday April 16, 2011 @09:04PM (#2455307)
This move also signals to the community that bcrypt is considered a best practice, important enough that it's included by default.

bcrypt has been considered a best practice for quite a while. it's been openbsd's default password hashing scheme since 1997, and used in a number of php projects like drupal, phpbb, and wordpress for many years.

Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by swaits on Saturday April 16, 2011 @10:40PM (#2455436)
Yup. That hasn't stopped hordes of devs from doing stupid things with passwords. My point is that now, at least for Rails, bcrypt is harder to ignore. And that's a good thing.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by damoncali on Saturday April 16, 2011 @08:31PM (#2455249)
I hope so. It's a real pain to switch gems when the auth of the week is left for dead.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by zmanji on Saturday April 16, 2011 @09:25PM (#2455333)
Agreed. Switching authentication gems is incredibly painful. Sometimes I think the best solution is to use the "low-level" gems like warden and always craft an authentication system myself.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by moe on Saturday April 16, 2011 @10:53PM (#2455452)
That reminds me, which is the auth gem of the week currently, Devise?
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by ludicast on Sunday April 17, 2011 @10:51PM (#2457771)
Devise is excellent. Jose Valim's gems tend to become standards pretty quickly.
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by riffraff on Sunday April 17, 2011 @06:41AM (#2455904)
for large values of "week", the railscast for devise is more than year old, and it had already gained quite a lot of mind share by then
Re:Exploring Rails 3.1 - ActiveModel::SecurePassword by oscardelben on Sunday April 17, 2011 @04:15AM (#2455783)
Devise with omniauth if you want multiple logins