Deprecated ROLE_PREVIOUS_ADMIN

This commit is contained in:
Wouter de Jong 2020-02-25 13:05:26 +01:00
parent ff9b8dae88
commit dce55f352a
3 changed files with 17 additions and 1 deletions

View File

@ -40,6 +40,10 @@ class RoleVoter implements VoterInterface
continue;
}
if ('ROLE_PREVIOUS_ADMIN' === $attribute) {
trigger_deprecation('symfony/security-core', '5.1', 'The ROLE_PREVIOUS_ADMIN role is deprecated and will be removed in version 6.0, use the IS_IMPERSONATOR attribute instead.');
}
$result = VoterInterface::ACCESS_DENIED;
foreach ($roles as $role) {
if ($attribute === $role) {

View File

@ -44,6 +44,17 @@ class RoleVoterTest extends TestCase
];
}
/**
* @group legacy
* @expectedDeprecation Since symfony/security-core 5.1: The ROLE_PREVIOUS_ADMIN role is deprecated and will be removed in version 6.0, use the IS_IMPERSONATOR attribute instead.
*/
public function testDeprecatedRolePreviousAdmin()
{
$voter = new RoleVoter();
$voter->vote($this->getTokenWithRoleNames(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN']), null, ['ROLE_PREVIOUS_ADMIN']);
}
protected function getTokenWithRoleNames(array $roles)
{
$token = $this->getMockBuilder(AbstractToken::class)->getMock();

View File

@ -18,7 +18,8 @@
"require": {
"php": "^7.2.5",
"symfony/event-dispatcher-contracts": "^1.1|^2",
"symfony/service-contracts": "^1.1.6|^2"
"symfony/service-contracts": "^1.1.6|^2",
"symfony/deprecation-contracts": "^2.1"
},
"require-dev": {
"psr/container": "^1.0",