Skip to content

Commit

Permalink
bug #22858 [SecurityBundle] Prevent auto-registration of UserPassword…
Browse files Browse the repository at this point in the history
…EncoderCommand (chalasr)

This PR was merged into the 3.3 branch.

Discussion
----------

[SecurityBundle] Prevent auto-registration of UserPasswordEncoderCommand

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22855
| License       | MIT
| Doc PR        | n/a

Always registers the command as a service even if no encoders are configured so that it is not auto-registered via reflection.
Prevents an irrelevant deprecation when no encoders are configured and, if a day the per-convention command registration is removed, ensures that the command always exists (leading to an exception saying that you have no configured encoder, better than nothing).
ping @ogizanagi

Commits
-------

b39b35b Prevent auto-registration of UserPasswordEncoderCommand
  • Loading branch information
nicolas-grekas committed May 23, 2017
2 parents 4d93e14 + b39b35b commit bca7b41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -98,11 +98,11 @@ public function load(array $configs, ContainerBuilder $container)

if ($config['encoders']) {
$this->createEncoders($config['encoders'], $container);
}

if (class_exists(Application::class)) {
$loader->load('console.xml');
$container->getDefinition('security.console.user_password_encoder_command')->replaceArgument(1, array_keys($config['encoders']));
}
if (class_exists(Application::class)) {
$loader->load('console.xml');
$container->getDefinition('security.console.user_password_encoder_command')->replaceArgument(1, array_keys($config['encoders']));
}

// load ACL
Expand Down
Expand Up @@ -345,6 +345,11 @@ public function testUserCheckerConfigWithNoCheckers()
$this->assertEquals('security.user_checker', $this->getContainer('container1')->getAlias('security.user_checker.secure'));
}

public function testUserPasswordEncoderCommandIsRegistered()
{
$this->assertTrue($this->getContainer('remember_me_options')->has('security.console.user_password_encoder_command'));
}

protected function getContainer($file)
{
$file = $file.'.'.$this->getFileExtension();
Expand Down

0 comments on commit bca7b41

Please sign in to comment.