Commit 570cffad authored by Fabien Potencier's avatar Fabien Potencier

bug #1606 Fix validator integration into the security provider (fabpot)

This PR was merged into the 2.2.x-dev branch.

Discussion
----------

Fix validator integration into the security provider

replaces #1550, fixes #1531

Commits
-------

8166816e fixed validator integration into the security provider
parents 44c87161 8166816e
...@@ -4,6 +4,7 @@ Changelog ...@@ -4,6 +4,7 @@ Changelog
2.2.3 (2018-XX-XX) 2.2.3 (2018-XX-XX)
------------------ ------------------
* fixed validator integration into the security provider (order of registration of the validator and security providers does not matter anymore)
* fixed compatibility issues with Symfony 3.4 * fixed compatibility issues with Symfony 3.4
2.2.2 (2018-01-12) 2.2.2 (2018-01-12)
......
...@@ -151,6 +151,14 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -151,6 +151,14 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
}; };
$app['security.firewall'] = function ($app) { $app['security.firewall'] = function ($app) {
if (isset($app['validator'])) {
$app['security.validator.user_password_validator'] = function ($app) {
return new UserPasswordValidator($app['security.token_storage'], $app['security.encoder_factory']);
};
$app['validator.validator_service_ids'] = array_merge($app['validator.validator_service_ids'], ['security.validator.user_password' => 'security.validator.user_password_validator']);
}
return new Firewall($app['security.firewall_map'], $app['dispatcher']); return new Firewall($app['security.firewall_map'], $app['dispatcher']);
}; };
...@@ -657,14 +665,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -657,14 +665,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
return new AnonymousAuthenticationProvider($name); return new AnonymousAuthenticationProvider($name);
}; };
}); });
if (isset($app['validator'])) {
$app['security.validator.user_password_validator'] = function ($app) {
return new UserPasswordValidator($app['security.token_storage'], $app['security.encoder_factory']);
};
$app['validator.validator_service_ids'] = array_merge($app['validator.validator_service_ids'], ['security.validator.user_password' => 'security.validator.user_password_validator']);
}
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
......
...@@ -146,7 +146,6 @@ class SecurityServiceProviderTest extends WebTestCase ...@@ -146,7 +146,6 @@ class SecurityServiceProviderTest extends WebTestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new ValidatorServiceProvider());
$app->register(new SecurityServiceProvider(), [ $app->register(new SecurityServiceProvider(), [
'security.firewalls' => [ 'security.firewalls' => [
'admin' => [ 'admin' => [
...@@ -158,6 +157,7 @@ class SecurityServiceProviderTest extends WebTestCase ...@@ -158,6 +157,7 @@ class SecurityServiceProviderTest extends WebTestCase
], ],
], ],
]); ]);
$app->register(new ValidatorServiceProvider());
$app->boot(); $app->boot();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment