Skip to content

[Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible #34140

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

Merged
merged 1 commit into from
Oct 28, 2019

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Oct 27, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

sodium implementations are always faster, let's use them when possible. This also allows validating argon2 passwords when bcrypt is configured as the main one, making migrations possible.

@nicolas-grekas nicolas-grekas changed the base branch from 4.4 to 4.3 October 28, 2019 07:38
@nicolas-grekas nicolas-grekas modified the milestones: 4.4, 4.3 Oct 28, 2019
@nicolas-grekas
Copy link
Member Author

PR rebased on 4.3

@chalasr
Copy link
Member

chalasr commented Oct 28, 2019

Thank you @nicolas-grekas.

chalasr added a commit that referenced this pull request Oct 28, 2019
…alidate passwords when possible (nicolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

sodium implementations are always faster, let's use them when possible. This also allows validating argon2 passwords when bcrypt is configured as the main one, making migrations possible.

Commits
-------

799a2ea [Security/Core] make NativePasswordEncoder use sodium to validate passwords when possible
@chalasr chalasr merged commit 799a2ea into symfony:4.3 Oct 28, 2019
@nicolas-grekas nicolas-grekas deleted the sec-nat-na branch October 30, 2019 13:53
@fabpot fabpot mentioned this pull request Nov 1, 2019
@@ -45,7 +45,7 @@ public function __construct(int $opsLimit = null, int $memLimit = null, int $cos
throw new \InvalidArgumentException('$cost must be in the range of 4-31.');
}

$this->algo = \defined('PASSWORD_ARGON2I') ? max(PASSWORD_DEFAULT, \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : PASSWORD_ARGON2I) : PASSWORD_DEFAULT;
$this->algo = \defined('PASSWORD_ARGON2ID') ? PASSWORD_ARGON2ID : (\defined('PASSWORD_ARGON2I') ? PASSWORD_ARGON2I : PASSWORD_BCRYPT);
Copy link
Member

Choose a reason for hiding this comment

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

your plan initially was to always be at least as good as PASSWORD_DEFAULT, even if PHP upgrades it. Is this plan gone ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, the plan is gone: in 7.4, PASSWORD_DEFAULT === null and other PASSWORD_* consts are strings; this makes it too difficult to maintain the plan.

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

Successfully merging this pull request may close these issues.

4 participants