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

[6.x] Handle argon failures robustly #33856

Merged
merged 1 commit into from
Aug 13, 2020
Merged

[6.x] Handle argon failures robustly #33856

merged 1 commit into from
Aug 13, 2020

Conversation

GrahamCampbell
Copy link
Member

No description provided.

@@ -60,13 +60,13 @@ public function __construct(array $options = [])
*/
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
Member 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.

3 participants