You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end()
@trigger_error('Configuring an encoder with "argon2i" as algorithm is deprecated since Symfony 4.3, use "auto" instead.', E_USER_DEPRECATED);
557
+
if (SodiumPasswordEncoder::isSupported() && !($hasSodiumArgon2id = \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13'))) {
558
+
return [
559
+
'class' => SodiumPasswordEncoder::class,
560
+
'arguments' => [
561
+
$config['time_cost'] ?? null,
562
+
(($config['memory_cost'] ?? 0) << 10) ?: null,
563
+
],
564
+
];
565
+
}
552
566
553
-
if (!Argon2iPasswordEncoder::isSupported()) {
554
-
if (\extension_loaded('sodium') && !\defined('SODIUM_CRYPTO_PWHASH_SALTBYTES')) {
555
-
thrownewInvalidConfigurationException('The installed libsodium version does not have support for Argon2i. Use "auto" instead.');
567
+
if (!\defined('PASSWORD_ARGON2I')) {
568
+
if ($hasSodiumArgon2id ?? false) {
569
+
thrownewInvalidConfigurationException('Algorithm "argon2i" is not available. You should either use "argon2id", downgrade your sodium extension or use a different encoder.');
556
570
}
571
+
thrownewInvalidConfigurationException('Algorithm "argon2i" is not available. You should either install the sodium extension, upgrade to PHP 7.2+ or use a different encoder.');
572
+
}
557
573
558
-
thrownewInvalidConfigurationException('Argon2i algorithm is not supported. Install the libsodium extension or use "auto" instead.');
574
+
return [
575
+
'class' => NativePasswordEncoder::class,
576
+
'arguments' => [
577
+
$config['time_cost'] ?? null,
578
+
(($config['memory_cost'] ?? 0) << 10) ?: null,
579
+
$config['cost'] ?? null,
580
+
\PASSWORD_ARGON2I,
581
+
],
582
+
];
583
+
}
584
+
585
+
if ('argon2id' === $config['algorithm']) {
586
+
if (($hasSodium = SodiumPasswordEncoder::isSupported()) && \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13')) {
587
+
return [
588
+
'class' => SodiumPasswordEncoder::class,
589
+
'arguments' => [
590
+
$config['time_cost'] ?? null,
591
+
(($config['memory_cost'] ?? 0) << 10) ?: null,
592
+
],
593
+
];
594
+
}
595
+
596
+
if (!\defined('PASSWORD_ARGON2ID')) {
597
+
if (\defined('PASSWORD_ARGON2I') || $hasSodium) {
598
+
thrownewInvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. You can either use "argon2i", upgrade to PHP 7.3+, %s sodium extension or use a different encoder.', $hasSodium ? 'upgrade your' : 'install the'));
599
+
}
600
+
thrownewInvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. You should either %s sodium extension, upgrade to PHP 7.3+ or use a different encoder.', $hasSodium ? 'upgrade your' : 'install the'));
0 commit comments