Skip to content

Conversation

@GrahamCampbell
Copy link
Collaborator

No description provided.

public function make($value, array $options = [])
{
$hash = password_hash($value, $this->algorithm(), [
$hash = @password_hash($value, $this->algorithm(), [
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we want the error suppression here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeh, we do want it, otherwise the code bellow doesn't run always. The idea here is that we wanna have a standard interface to our hasher on both PHP 7 and PHP 8. If it fails, they we should always get a laravel exception out the other end.

@taylorotwell taylorotwell merged commit a586ad4 into 6.x Aug 13, 2020
@GrahamCampbell GrahamCampbell deleted the argon-fixes branch August 13, 2020 14:28
browner12 added a commit to browner12/framework that referenced this pull request Dec 10, 2024
as of PHP 8.0.0, `password_hash()` no longer returns false on failure, instead a `ValueError` will be thrown if the password hashing algorithm is not valid, or an `Error` if the password hashing failed for an unknown error.

I noticed the `ArgonHasher` already had a slightly updated check using error suppression, which was added in laravel#33856.  however, I couldn't seem to get that to actually work, and for consistency I updated them both to use try/catch.

added tests for all 3 implementations to see if they correctly throw a `RuntimeException` if they are not able to be created.  I used invalid "cost" and "time" options to trigger this. not sure if there's a better way.

https://www.php.net/manual/en/function.password-hash.php#:~:text=the%20salt%20generation.-,8.0.0,-password_hash()%20no
taylorotwell pushed a commit that referenced this pull request Dec 10, 2024
* handle `password_hash()` failures better

as of PHP 8.0.0, `password_hash()` no longer returns false on failure, instead a `ValueError` will be thrown if the password hashing algorithm is not valid, or an `Error` if the password hashing failed for an unknown error.

I noticed the `ArgonHasher` already had a slightly updated check using error suppression, which was added in #33856.  however, I couldn't seem to get that to actually work, and for consistency I updated them both to use try/catch.

added tests for all 3 implementations to see if they correctly throw a `RuntimeException` if they are not able to be created.  I used invalid "cost" and "time" options to trigger this. not sure if there's a better way.

https://www.php.net/manual/en/function.password-hash.php#:~:text=the%20salt%20generation.-,8.0.0,-password_hash()%20no

* minor formatting
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.

4 participants