Commit 5b7f26c2 authored by Fabien Potencier's avatar Fabien Potencier

dropped Symfony 2.6 compatibility

parent 222592a3
...@@ -18,39 +18,39 @@ ...@@ -18,39 +18,39 @@
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"pimple/pimple": "~3.0", "pimple/pimple": "~3.0",
"symfony/event-dispatcher": "~2.6", "symfony/event-dispatcher": "~2.7",
"symfony/http-foundation": "~2.6", "symfony/http-foundation": "~2.7",
"symfony/http-kernel": "~2.6", "symfony/http-kernel": "~2.7",
"symfony/routing": "~2.6" "symfony/routing": "~2.7"
}, },
"require-dev": { "require-dev": {
"symfony/security": "~2.6", "symfony/security": "~2.7",
"symfony/config": "~2.6", "symfony/config": "~2.7",
"symfony/locale": "~2.6", "symfony/locale": "~2.7",
"symfony/form": "~2.6", "symfony/form": "~2.7",
"symfony/browser-kit": "~2.6", "symfony/browser-kit": "~2.7",
"symfony/css-selector": "~2.6", "symfony/css-selector": "~2.7",
"symfony/debug": "~2.6", "symfony/debug": "~2.7",
"symfony/dom-crawler": "~2.6", "symfony/dom-crawler": "~2.7",
"symfony/finder": "~2.6", "symfony/finder": "~2.7",
"symfony/monolog-bridge": "~2.6", "symfony/monolog-bridge": "~2.7",
"symfony/doctrine-bridge": "~2.6", "symfony/doctrine-bridge": "~2.7",
"symfony/options-resolver": "~2.6", "symfony/options-resolver": "~2.7",
"symfony/process": "~2.6", "symfony/process": "~2.7",
"symfony/serializer": "~2.6", "symfony/serializer": "~2.7",
"symfony/translation": "~2.6", "symfony/translation": "~2.7",
"symfony/twig-bridge": "~2.6", "symfony/twig-bridge": "~2.7",
"symfony/validator": "~2.6", "symfony/validator": "~2.7",
"twig/twig": ">=1.8.0,<2.0-dev", "twig/twig": ">=1.8.0,<2.0-dev",
"doctrine/dbal": "~2.2", "doctrine/dbal": "~2.2",
"swiftmailer/swiftmailer": "5.*", "swiftmailer/swiftmailer": "5.*",
"monolog/monolog": "~1.4,>=1.4.1" "monolog/monolog": "~1.4,>=1.4.1"
}, },
"suggest": { "suggest": {
"symfony/browser-kit": "~2.6", "symfony/browser-kit": "~2.7",
"symfony/css-selector": "~2.6", "symfony/css-selector": "~2.7",
"symfony/dom-crawler": "~2.6", "symfony/dom-crawler": "~2.7",
"symfony/form": "~2.6" "symfony/form": "~2.7"
}, },
"replace": { "replace": {
"silex/api": "self.version", "silex/api": "self.version",
......
...@@ -4,6 +4,7 @@ Changelog ...@@ -4,6 +4,7 @@ Changelog
2.0.0 (2014-XX-XX) 2.0.0 (2014-XX-XX)
------------------ ------------------
* bumped minimum version of Symfony to 2.7
* bumped minimum version of PHP to 5.5.0 * bumped minimum version of PHP to 5.5.0
* Updated Pimple to 3.0 * Updated Pimple to 3.0
* Updated session listeners to extends HttpKernel ones * Updated session listeners to extends HttpKernel ones
......
...@@ -13,13 +13,10 @@ Parameters ...@@ -13,13 +13,10 @@ Parameters
Services Services
-------- --------
* **security**: The main entry point for the security provider. Use it to get * **security.token_storage**: Gives access to the user token.
the current user token (only for Symfony up to 2.5).
* **security.token_storage**: Gives access to the user token (Symfony 2.6+).
* **security.authorization_checker**: Allows to check authorizations for the * **security.authorization_checker**: Allows to check authorizations for the
users (Symfony 2.6+). users.
* **security.authentication_manager**: An instance of * **security.authentication_manager**: An instance of
`AuthenticationProviderManager `AuthenticationProviderManager
...@@ -102,12 +99,8 @@ Accessing the current User ...@@ -102,12 +99,8 @@ Accessing the current User
The current user information is stored in a token that is accessible via the The current user information is stored in a token that is accessible via the
``security`` service:: ``security`` service::
// Symfony 2.6+
$token = $app['security.token_storage']->getToken(); $token = $app['security.token_storage']->getToken();
// Symfony 2.3/2.5
$token = $app['security']->getToken();
If there is no information about the user, the token is ``null``. If the user If there is no information about the user, the token is ``null``. If the user
is known, you can get it with a call to ``getUser()``:: is known, you can get it with a call to ``getUser()``::
...@@ -338,16 +331,10 @@ Checking User Roles ...@@ -338,16 +331,10 @@ Checking User Roles
To check if a user is granted some role, use the ``isGranted()`` method on the To check if a user is granted some role, use the ``isGranted()`` method on the
security context:: security context::
// Symfony 2.6+
if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) { if ($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) {
// ... // ...
} }
// Symfony 2.3/2.5
if ($app['security']->isGranted('ROLE_ADMIN')) {
// ...
}
You can check roles in Twig templates too: You can check roles in Twig templates too:
.. code-block:: jinja .. code-block:: jinja
...@@ -583,7 +570,6 @@ use in your configuration:: ...@@ -583,7 +570,6 @@ use in your configuration::
// define the authentication listener object // define the authentication listener object
$app['security.authentication_listener.'.$name.'.wsse'] = function () use ($app) { $app['security.authentication_listener.'.$name.'.wsse'] = function () use ($app) {
// use 'security' instead of 'security.token_storage' on Symfony <2.6
return new WsseListener($app['security.token_storage'], $app['security.authentication_manager']); return new WsseListener($app['security.token_storage'], $app['security.authentication_manager']);
}; };
......
...@@ -80,10 +80,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -80,10 +80,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
$app['security.access_rules'] = array(); $app['security.access_rules'] = array();
$app['security.hide_user_not_found'] = true; $app['security.hide_user_not_found'] = true;
// the else part of this condition can be removed as soon as the Symfony 2.6 compat is removed
$r = new \ReflectionMethod('Symfony\Component\Security\Http\Firewall\ContextListener', '__construct');
$params = $r->getParameters();
if ('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' === $params[0]->getClass()->getName()) {
$app['security.authorization_checker'] = function ($app) { $app['security.authorization_checker'] = function ($app) {
return new AuthorizationChecker($app['security.token_storage'], $app['security.authentication_manager'], $app['security.access_manager']); return new AuthorizationChecker($app['security.token_storage'], $app['security.authentication_manager'], $app['security.access_manager']);
}; };
...@@ -92,19 +88,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -92,19 +88,6 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
return new TokenStorage(); return new TokenStorage();
}; };
$app['security'] = function ($app) {
return new SecurityContext($app['security.token_storage'], $app['security.authorization_checker']);
};
} else {
$app['security.token_storage'] = $app['security.authorization_checker'] = function ($app) {
return $app['security'];
};
$app['security'] = function ($app) {
return new SecurityContext($app['security.authentication_manager'], $app['security.access_manager']);
};
}
$app['user'] = $app->factory(function ($app) { $app['user'] = $app->factory(function ($app) {
if (null === $token = $app['security.token_storage']->getToken()) { if (null === $token = $app['security.token_storage']->getToken()) {
return; return;
......
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