diff --git a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php index c93cb4987f481..0df89403a82a0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php @@ -19,8 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; +use Symfony\Component\Security\Core\Encoder\SelfSaltingEncoderInterface; use Symfony\Component\Security\Core\User\User; /** @@ -117,9 +117,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $encoderFactory = $this->encoderFactory ?: $this->getContainer()->get('security.encoder_factory'); $encoder = $encoderFactory->getEncoder($userClass); - $bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder; + $saltlessWithoutEmptySalt = !$emptySalt && $encoder instanceof SelfSaltingEncoderInterface; - if ($bcryptWithoutEmptySalt) { + if ($saltlessWithoutEmptySalt) { $emptySalt = true; } @@ -161,8 +161,8 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$emptySalt) { $errorIo->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt))); - } elseif ($bcryptWithoutEmptySalt) { - $errorIo->note('Bcrypt encoder used: the encoder generated its own built-in salt.'); + } elseif ($saltlessWithoutEmptySalt) { + $errorIo->note('Self-salting encoder used: the encoder generated its own built-in salt.'); } $errorIo->success('Password encoding succeeded'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 0710f94b5b094..afd3da09ce0d2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -120,13 +120,11 @@ public function testEncodePasswordEmptySaltOutput() public function testEncodePasswordBcryptOutput() { - $this->passwordEncoderCommandTester->execute( - array( - 'command' => 'security:encode-password', - 'password' => 'p@ssw0rd', - 'user-class' => 'Custom\Class\Bcrypt\User', - ) - ); + $this->passwordEncoderCommandTester->execute(array( + 'command' => 'security:encode-password', + 'password' => 'p@ssw0rd', + 'user-class' => 'Custom\Class\Bcrypt\User', + ), array('interactive' => false)); $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } diff --git a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php index 8278ef34fa625..8c09660a35315 100644 --- a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php @@ -17,7 +17,7 @@ * @author Elnur Abdurrakhimov * @author Terje BrĂ¥ten */ -class BCryptPasswordEncoder extends BasePasswordEncoder +class BCryptPasswordEncoder extends BasePasswordEncoder implements SelfSaltingEncoderInterface { const MAX_PASSWORD_LENGTH = 72; diff --git a/src/Symfony/Component/Security/Core/Encoder/SelfSaltingEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/SelfSaltingEncoderInterface.php new file mode 100644 index 0000000000000..37855b60cff83 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Encoder/SelfSaltingEncoderInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Encoder; + +/** + * SelfSaltingEncoderInterface is a marker interface for encoders that do not + * require a user-generated salt. + * + * @author Zan Baldwin + */ +interface SelfSaltingEncoderInterface +{ +}