lundi 15 octobre 2018

Modifying the authenticate_user function to support laravels non-standard bcrypt notation

I have a rails application that is using a Users table that was generated and filled via a laravel application.

the issue I'm having relates to another stackoverflow post

Migrating users table from Laravel to Ruby and using BCrypt to decode passwords does not work

I need both applications to continue to work, but all the users are currently using PHPs non-standard notation for bcrypt-hashed passwords. The conversion is pretty easy. @tadman posted a solution on how to use the laravel generated password in ruby

BCrypt::Password.new(hash.sub(/\A\$2y/, '$2a'))

but now I'm trying to figure out how to actually use this for the rails authentication...

I've been looking into monkeypatching the authenticate_user method from ActiveModel::SecurePassword class but not sure if that is a good way to approach this.

Another way that I was thinking is making the appropriate change to all the users encrypted passwords to make them conform to the standard Bcrypt format, but then I would need to make the change to login on the laravel side... Ether way I have to change the implemention somewhere.

Is there a way that is less invasive into library code?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire