minor #26190 [SecurityBundle] Improve error when argon2i is not available (Coffee2CodeNL)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[SecurityBundle] Improve error when argon2i is not available

| Q             | A
| ------------- | ---
| Branch?       | master?
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | ?
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Commits
-------

eb6436ac82 [SecurityBundle] Improve error when argon2i is not available
This commit is contained in:
Fabien Potencier 2018-10-12 15:48:32 -07:00
commit 8199809fe5

View File

@ -566,7 +566,11 @@ class SecurityExtension extends Extension implements PrependExtensionInterface
// Argon2i encoder
if ('argon2i' === $config['algorithm']) {
if (!Argon2iPasswordEncoder::isSupported()) {
throw new InvalidConfigurationException('Argon2i algorithm is not supported. Please install the libsodium extension or upgrade to PHP 7.2+.');
if (\extension_loaded('sodium') && !\defined('SODIUM_CRYPTO_PWHASH_SALTBYTES')) {
throw new InvalidConfigurationException('The installed libsodium version does not have support for Argon2i. Use Bcrypt instead.');
}
throw new InvalidConfigurationException('Argon2i algorithm is not supported. Install the libsodium extension or use BCrypt instead.');
}
return array(