Commit 84f595dd authored by Fabien Potencier's avatar Fabien Potencier

forced the security to be setup properly when accessed outside of the handling...

forced the security to be setup properly when accessed outside of the handling of a request (refs #473)
parent 2b28989b
...@@ -45,7 +45,9 @@ Registering ...@@ -45,7 +45,9 @@ Registering
.. code-block:: php .. code-block:: php
$app->register(new Silex\Provider\SecurityServiceProvider()); $app->register(new Silex\Provider\SecurityServiceProvider(array(
'security.firewalls' => // see below
)));
.. note:: .. note::
......
...@@ -71,6 +71,11 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -71,6 +71,11 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.access_rules'] = array(); $app['security.access_rules'] = array();
$app['security'] = $app->share(function ($app) { $app['security'] = $app->share(function ($app) {
// First, force everything to be setup correctly.
// This is needed when using the Security provider outside
// of the handling of a request
$app['security.listener'];
return new SecurityContext($app['security.authentication_manager'], $app['security.access_manager']); return new SecurityContext($app['security.authentication_manager'], $app['security.access_manager']);
}); });
......
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