Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Start adding argon hashing support. #21885

Merged
merged 7 commits into from
Nov 6, 2017
Merged

[5.6] Start adding argon hashing support. #21885

merged 7 commits into from
Nov 6, 2017

Conversation

morloderex
Copy link
Contributor

@morloderex morloderex commented Oct 30, 2017

Hello everyone.

With the release of php 7.2 which is due to be released at the end of november Argon 2i password hashing was added. rfc for reference

So i have added support of both bcrypt and Argon2i password hashing. Simply by adding a new class. And returning a password manager within the serviceProvider.

Note: Argon2i password hashing is only availiable if a speciel confuration flag is passed during php compile time.

Edit: If ypu are on a mac and is using homebrew i added the ability to compile php 7.2 with the correct configuration flag. use the fallowing command brew install php72 --with-argon2 if you want to test it.

@paulofreitas
Copy link
Contributor

Seems a good starting point. 👍

@abhimanyu003
Copy link
Contributor

Interesting 👍

Copy link
Contributor

@juukie juukie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would at a dot at the end of this line

@taylorotwell
Copy link
Member

The bcrypt helper would need to be forcing the Bcrypt implementation.

@Miguel-Serejo
Copy link

Would it make sense to also add a hash() helper that uses whatever driver is set as default?

@m1guelpf
Copy link
Contributor

@36864 hash() is already a PHP function. Also, another name for a hash helper has been widely discussed, but we didn't get to anything.

@Miguel-Serejo
Copy link

Miguel-Serejo commented Oct 31, 2017 via email

@morloderex
Copy link
Contributor Author

morloderex commented Oct 31, 2017

I’ll leave that up to @taylorotwell to decide.

@paulofreitas
Copy link
Contributor

Some discussions on this topic just for further discussion:

The only thing decided is that, if helpers have to change at some point, the bcrypt() helper would still be included and deprecated in the next major release following the deprecation promise. 👍

@taylorotwell
Copy link
Member

I don't really want to add any new helpers, I just want to force bcrypt to the Bcrypt implementation.

@morloderex
Copy link
Contributor Author

It should already be forcing the correct implementation if it’s not can you point me in the right direction?

I’ll remove the new helper I added.

@morloderex
Copy link
Contributor Author

Removed the helper.

@taylorotwell
Copy link
Member

Do you see that you have failing tests?

@OwenMelbz
Copy link
Contributor

The travis environments look like they would need to have argon enabled on the php install - is that something the community can adjust or only @taylorotwell ?

@morloderex
Copy link
Contributor Author

@taylorotwell The failing tests on travis should now have been resolved.

@taylorotwell
Copy link
Member

Why did you make another binding for bcrypt? Is that really the way to solve the issue?

@morloderex
Copy link
Contributor Author

Maybe i was thinking of this wrong the wrong way. But sense the manager before just returned whatever was set as the default driver. Forcing bcrypt in the bcrypt helper made it very difficult. Spilting up the bindings makes this a lot easier. But if you know any other way i could do this without another binding some directions will be helpful :)

@taylorotwell
Copy link
Member

Why would the helper not do app('hash')->driver('bcrypt')... am I missing something?

@taylorotwell
Copy link
Member

I think everything else looks pretty fine if we can work out this binding issue.

@taylorotwell taylorotwell merged commit c272b15 into laravel:master Nov 6, 2017
@taylorotwell
Copy link
Member

Fixed the broken tests you were having.

@BenExile
Copy link

BenExile commented Nov 9, 2017

I added Argon2 hashing support for 5.5 (with a dependency on libsodium) in #21524 and this was closed. PHP 7.2 is approaching stable, but it would be great to see backwards compatibility with >= 7.0.

@ericdowell
Copy link
Contributor

The command to install PHP 7.2 with argon hashing for MacOS (homebrew) listed in the PR description is missing the number 2 in the with flag.

The command is: brew install php72 --with-argon2

@bolajipemipo
Copy link

A little light needed here @taylorotwell @morloderex

For an existing application that uses bcrypt, which means the passwords were hashed using bcrypt, won't changing the config to argon (for newer signups) affect the decrypting of the earlier "bcrypted" passwords?

@BenExile
Copy link

BenExile commented Mar 6, 2018

The ArgonHasher::check() method uses PHP's built-in password_verify function, so users with passwords using the bcrypt algorithm will still be able to log in. You would need to check at the time of login whether the hash used the correct algorithm and options, and rehash if required:

// The user credentials have been verified prior to this step

if (Hash::needsRehash($hashedPassword)) {
    $user->password = Hash::make($plainTextPassword);
    $user->save();
}

@bolajipemipo
Copy link

@BenExile, thanks. Will check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.