Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
5b7f26c2
Commit
5b7f26c2
authored
Jun 14, 2015
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dropped Symfony 2.6 compatibility
parent
222592a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
64 deletions
+34
-64
composer.json
composer.json
+25
-25
doc/changelog.rst
doc/changelog.rst
+1
-0
doc/providers/security.rst
doc/providers/security.rst
+2
-16
src/Silex/Provider/SecurityServiceProvider.php
src/Silex/Provider/SecurityServiceProvider.php
+6
-23
No files found.
composer.json
View file @
5b7f26c2
...
@@ -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"
,
...
...
doc/changelog.rst
View file @
5b7f26c2
...
@@ -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
...
...
doc/providers/security.rst
View file @
5b7f26c2
...
@@ -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']);
};
};
...
...
src/Silex/Provider/SecurityServiceProvider.php
View file @
5b7f26c2
...
@@ -80,30 +80,13 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
...
@@ -80,30 +80,13 @@ 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
$app
[
'security.authorization_checker'
]
=
function
(
$app
)
{
$r
=
new
\ReflectionMethod
(
'Symfony\Component\Security\Http\Firewall\ContextListener'
,
'__construct'
);
return
new
AuthorizationChecker
(
$app
[
'security.token_storage'
],
$app
[
'security.authentication_manager'
],
$app
[
'security.access_manager'
]);
$params
=
$r
->
getParameters
();
};
if
(
'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
===
$params
[
0
]
->
getClass
()
->
getName
())
{
$app
[
'security.authorization_checker'
]
=
function
(
$app
)
{
return
new
AuthorizationChecker
(
$app
[
'security.token_storage'
],
$app
[
'security.authentication_manager'
],
$app
[
'security.access_manager'
]);
};
$app
[
'security.token_storage'
]
=
function
(
$app
)
{
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
)
{
$app
[
'security.token_storage'
]
=
function
(
$app
)
{
return
new
SecurityContext
(
$app
[
'security.authentication_manager'
],
$app
[
'security.access_manager'
]);
return
new
TokenStorage
();
};
};
}
$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
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment