Skip to content

[5.6] Start adding argon hashing support.#21885

Merged
taylorotwell merged 7 commits into
laravel:masterfrom
morloderex:add_argon2_support
Nov 6, 2017
Merged

[5.6] Start adding argon hashing support.#21885
taylorotwell merged 7 commits into
laravel:masterfrom
morloderex:add_argon2_support

Conversation

@morloderex

@morloderex morloderex commented Oct 30, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Seems a good starting point. 👍

@abhimanyu003

Copy link
Copy Markdown
Contributor

Interesting 👍

@juukie juukie left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@Miguel-Serejo

Copy link
Copy Markdown

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

@m1guelpf

Copy link
Copy Markdown
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

Miguel-Serejo commented Oct 31, 2017 via email

Copy link
Copy Markdown

@morloderex

morloderex commented Oct 31, 2017

Copy link
Copy Markdown
Contributor Author

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

@paulofreitas

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@morloderex

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Removed the helper.

@taylorotwell

Copy link
Copy Markdown
Member

Do you see that you have failing tests?

@OwenMelbz

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

@taylorotwell

Copy link
Copy Markdown
Member

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

@morloderex

Copy link
Copy Markdown
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
Copy Markdown
Member

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

@taylorotwell

Copy link
Copy Markdown
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
Copy Markdown
Member

Fixed the broken tests you were having.

@BenExile

BenExile commented Nov 9, 2017

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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

BenExile commented Mar 6, 2018

Copy link
Copy Markdown

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
Copy Markdown

@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.