minor #33696 [Security] tweak deprecation messages and changelog (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Security] tweak deprecation messages and changelog

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

eceb0e595c tweak deprecation messages and changelog
This commit is contained in:
Christian Flothmann 2019-09-25 11:52:51 +02:00
commit 51b7e030a8
3 changed files with 20 additions and 2 deletions

View File

@ -413,6 +413,24 @@ Routing
Security
--------
* Dropped support for passing more than one attribute to `AccessDecisionManager::decide()` and `AuthorizationChecker::isGranted()` (and indirectly the `is_granted()` Twig and ExpressionLanguage function):
**Before**
```php
if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) {
// ...
}
```
**After**
```php
if ($this->authorizationChecker->isGranted(new Expression("has_role('ROLE_USER') or has_role('ROLE_ADMIN')"))) {}
// or:
if ($this->authorizationChecker->isGranted('ROLE_USER')
|| $this->authorizationChecker->isGranted('ROLE_ADMIN')
) {}
```
* The `LdapUserProvider` class has been removed, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
* Implementations of `PasswordEncoderInterface` and `UserPasswordEncoderInterface` must have a new `needsRehash()` method
* The `Role` and `SwitchUserRole` classes have been removed.

View File

@ -58,7 +58,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface
public function decide(TokenInterface $token, array $attributes, $object = null)
{
if (\count($attributes) > 1) {
@trigger_error('Passing more than one Security attribute to '.__METHOD__.' is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', \E_USER_DEPRECATED);
@trigger_error(sprintf('Passing more than one Security attribute to %s() is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
}
return $this->{$this->strategy}($token, $attributes, $object);

View File

@ -56,7 +56,7 @@ class AuthorizationChecker implements AuthorizationCheckerInterface
if (!\is_array($attributes)) {
$attributes = [$attributes];
} else {
@trigger_error('Passing an array of Security attributes to '.__METHOD__.' is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', \E_USER_DEPRECATED);
@trigger_error(sprintf('Passing an array of Security attributes to %s() is deprecated since Symfony 4.4. Use multiple isGranted() calls or the expression language (e.g. "has_role(...) or has_role(...)") instead.', __METHOD__), E_USER_DEPRECATED);
}
return $this->accessDecisionManager->decide($token, $attributes, $subject);