Commit 33b352f8 authored by Fabien Potencier's avatar Fabien Potencier

renamed security.context to security

parent 2ebc4768
...@@ -12,8 +12,8 @@ n/a ...@@ -12,8 +12,8 @@ n/a
Services Services
-------- --------
* **security.context**: The main entry point for the security provider. Use it * **security**: The main entry point for the security provider. Use it to get
to get the current user token. the current user token.
* **security.authentication_manager**: An instance of * **security.authentication_manager**: An instance of
`AuthenticationProviderManager `AuthenticationProviderManager
...@@ -78,9 +78,9 @@ Accessing the current User ...@@ -78,9 +78,9 @@ 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.context`` service:: ``security`` service::
$token = $app['security.context']->getToken(); $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()``::
...@@ -281,7 +281,7 @@ Checking User Roles ...@@ -281,7 +281,7 @@ 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::
if ($app['security.context']->isGranted('ROLE_ADMIN') { if ($app['security']->isGranted('ROLE_ADMIN') {
// ... // ...
} }
......
...@@ -68,7 +68,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -68,7 +68,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.role_hierarchy'] = array(); $app['security.role_hierarchy'] = array();
$app['security.access_rules'] = array(); $app['security.access_rules'] = array();
$app['security.context'] = $app->share(function () use ($app) { $app['security'] = $app->share(function () use ($app) {
return new SecurityContext($app['security.authentication_manager'], $app['security.access_manager']); return new SecurityContext($app['security.authentication_manager'], $app['security.access_manager']);
}); });
...@@ -211,7 +211,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -211,7 +211,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.access_listener'] = $app->share(function () use ($app) { $app['security.access_listener'] = $app->share(function () use ($app) {
return new AccessListener( return new AccessListener(
$app['security.context'], $app['security'],
$app['security.access_manager'], $app['security.access_manager'],
$app['security.access_map'], $app['security.access_map'],
$app['security.authentication_manager'], $app['security.authentication_manager'],
...@@ -263,7 +263,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -263,7 +263,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.context_listener._proto'] = $app->protect(function ($providerKey, $userProviders) use ($app) { $app['security.context_listener._proto'] = $app->protect(function ($providerKey, $userProviders) use ($app) {
return new ContextListener( return new ContextListener(
$app['security.context'], $app['security'],
$userProviders, $userProviders,
$providerKey, $providerKey,
$app['logger'], $app['logger'],
...@@ -286,7 +286,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -286,7 +286,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
} }
return new ExceptionListener( return new ExceptionListener(
$app['security.context'], $app['security'],
$app['security.trust_resolver'], $app['security.trust_resolver'],
$app['security.http_utils'], $app['security.http_utils'],
$app['security.entry_point.'.$entryPoint.'.'.$name], $app['security.entry_point.'.$entryPoint.'.'.$name],
...@@ -300,7 +300,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -300,7 +300,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$that->addFakeRoute(array('post', $tmp = isset($options['check_path']) ? $options['check_path'] : '/login_check', str_replace('/', '_', ltrim($tmp, '/')))); $that->addFakeRoute(array('post', $tmp = isset($options['check_path']) ? $options['check_path'] : '/login_check', str_replace('/', '_', ltrim($tmp, '/'))));
return new UsernamePasswordFormAuthenticationListener( return new UsernamePasswordFormAuthenticationListener(
$app['security.context'], $app['security'],
$app['security.authentication_manager'], $app['security.authentication_manager'],
$app['security.session_strategy'], $app['security.session_strategy'],
$app['security.http_utils'], $app['security.http_utils'],
...@@ -316,7 +316,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -316,7 +316,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.authentication.http._proto'] = $app->protect(function ($providerKey, $options) use ($app) { $app['security.authentication.http._proto'] = $app->protect(function ($providerKey, $options) use ($app) {
return new BasicAuthenticationListener( return new BasicAuthenticationListener(
$app['security.context'], $app['security'],
$app['security.authentication_manager'], $app['security.authentication_manager'],
$providerKey, $providerKey,
$app['security.entry_point.http'], $app['security.entry_point.http'],
...@@ -326,7 +326,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -326,7 +326,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.authentication.anonymous._proto'] = $app->protect(function ($providerKey, $options) use ($app) { $app['security.authentication.anonymous._proto'] = $app->protect(function ($providerKey, $options) use ($app) {
return new AnonymousAuthenticationListener( return new AnonymousAuthenticationListener(
$app['security.context'], $app['security'],
$providerKey, $providerKey,
$app['logger'] $app['logger']
); );
...@@ -336,7 +336,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -336,7 +336,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$that->addFakeRoute(array('get', $tmp = isset($options['logout_path']) ? $options['logout_path'] : '/logout', str_replace('/', '_', ltrim($tmp, '/')))); $that->addFakeRoute(array('get', $tmp = isset($options['logout_path']) ? $options['logout_path'] : '/logout', str_replace('/', '_', ltrim($tmp, '/'))));
$listener = new LogoutListener( $listener = new LogoutListener(
$app['security.context'], $app['security'],
$app['security.http_utils'], $app['security.http_utils'],
$options, $options,
null, // LogoutSuccessHandlerInterface null, // LogoutSuccessHandlerInterface
...@@ -350,7 +350,7 @@ class SecurityServiceProvider implements ServiceProviderInterface ...@@ -350,7 +350,7 @@ class SecurityServiceProvider implements ServiceProviderInterface
$app['security.authentication.switch_user._proto'] = $app->protect(function ($name, $options) use ($app, $that) { $app['security.authentication.switch_user._proto'] = $app->protect(function ($name, $options) use ($app, $that) {
return new SwitchUserListener( return new SwitchUserListener(
$app['security.context'], $app['security'],
$app['security.user_provider.'.$name], $app['security.user_provider.'.$name],
$app['security.user_checker'], $app['security.user_checker'],
$name, $name,
......
...@@ -59,8 +59,8 @@ class TwigServiceProvider implements ServiceProviderInterface ...@@ -59,8 +59,8 @@ class TwigServiceProvider implements ServiceProviderInterface
$twig->addExtension(new TranslationExtension($app['translator'])); $twig->addExtension(new TranslationExtension($app['translator']));
} }
if (isset($app['security.context'])) { if (isset($app['security'])) {
$twig->addExtension(new SecurityExtension($app['security.context'])); $twig->addExtension(new SecurityExtension($app['security']));
} }
if (isset($app['form.factory'])) { if (isset($app['form.factory'])) {
......
...@@ -117,15 +117,15 @@ class SecurityServiceProviderTest extends WebTestCase ...@@ -117,15 +117,15 @@ class SecurityServiceProviderTest extends WebTestCase
}); });
$app->get('/', function() use ($app) { $app->get('/', function() use ($app) {
$user = $app['security.context']->getToken()->getUser(); $user = $app['security']->getToken()->getUser();
$content = is_object($user) ? $user->getUsername() : 'ANONYMOUS'; $content = is_object($user) ? $user->getUsername() : 'ANONYMOUS';
if ($app['security.context']->isGranted('IS_AUTHENTICATED_FULLY')) { if ($app['security']->isGranted('IS_AUTHENTICATED_FULLY')) {
$content .= 'AUTHENTICATED'; $content .= 'AUTHENTICATED';
} }
if ($app['security.context']->isGranted('ROLE_ADMIN')) { if ($app['security']->isGranted('ROLE_ADMIN')) {
$content .= 'ADMIN'; $content .= 'ADMIN';
} }
......
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