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

renamed security.context to security

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