Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0393724

Browse files
committed
[Security] deprecate the RoleInterface
1 parent 4033b60 commit 0393724

File tree

10 files changed

+39
-25
lines changed

10 files changed

+39
-25
lines changed

UPGRADE-3.3.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ ClassLoader
66

77
* The ApcClassLoader, WinCacheClassLoader and XcacheClassLoader classes have been deprecated
88
in favor of the `--apcu-autoloader` option introduced in composer 1.3
9+
10+
Security
11+
--------
12+
13+
* The `RoleInterface` has been deprecated. Extend the `Symfony\Component\Security\Core\Role\Role`
14+
class in your custom role implementations instead.

UPGRADE-4.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ HttpKernel
170170

171171
* The `DataCollector::varToString()` method has been removed in favor of `cloneVar()`.
172172

173+
Security
174+
--------
175+
176+
* The `RoleInterface` has been removed. Extend the `Symfony\Component\Security\Core\Role\Role`
177+
class instead.
178+
173179
Serializer
174180
----------
175181

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class AbstractToken implements TokenInterface
3333
/**
3434
* Constructor.
3535
*
36-
* @param RoleInterface[]|string[] $roles An array of roles
36+
* @param (Role|string)[] $roles An array of roles
3737
*
3838
* @throws \InvalidArgumentException
3939
*/

src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Token;
1313

14-
use Symfony\Component\Security\Core\Role\RoleInterface;
14+
use Symfony\Component\Security\Core\Role\Role;
1515

1616
/**
1717
* AnonymousToken represents an anonymous token.
@@ -25,9 +25,9 @@ class AnonymousToken extends AbstractToken
2525
/**
2626
* Constructor.
2727
*
28-
* @param string $secret A secret used to make sure the token is created by the app and not by a malicious client
29-
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
30-
* @param RoleInterface[] $roles An array of roles
28+
* @param string $secret A secret used to make sure the token is created by the app and not by a malicious client
29+
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
30+
* @param Role[] $roles An array of roles
3131
*/
3232
public function __construct($secret, $user, array $roles = array())
3333
{

src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Token;
1313

14-
use Symfony\Component\Security\Core\Role\RoleInterface;
14+
use Symfony\Component\Security\Core\Role\Role;
1515

1616
/**
1717
* PreAuthenticatedToken implements a pre-authenticated token.
@@ -26,10 +26,10 @@ class PreAuthenticatedToken extends AbstractToken
2626
/**
2727
* Constructor.
2828
*
29-
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
30-
* @param mixed $credentials The user credentials
31-
* @param string $providerKey The provider key
32-
* @param RoleInterface[]|string[] $roles An array of roles
29+
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
30+
* @param mixed $credentials The user credentials
31+
* @param string $providerKey The provider key
32+
* @param (Role|string)[] $roles An array of roles
3333
*/
3434
public function __construct($user, $credentials, $providerKey, array $roles = array())
3535
{

src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Token;
1313

14-
use Symfony\Component\Security\Core\Role\RoleInterface;
14+
use Symfony\Component\Security\Core\Role\Role;
1515

1616
/**
1717
* UsernamePasswordToken implements a username and password token.
@@ -26,10 +26,10 @@ class UsernamePasswordToken extends AbstractToken
2626
/**
2727
* Constructor.
2828
*
29-
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
30-
* @param string $credentials This usually is the password of the user
31-
* @param string $providerKey The provider key
32-
* @param RoleInterface[]|string[] $roles An array of roles
29+
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
30+
* @param string $credentials This usually is the password of the user
31+
* @param string $providerKey The provider key
32+
* @param (Role|string)[] $roles An array of roles
3333
*
3434
* @throws \InvalidArgumentException
3535
*/

src/Symfony/Component/Security/Core/Role/Role.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Role;
1313

1414
/**
15-
* Role is a simple implementation of a RoleInterface where the role is a
16-
* string.
15+
* Role is a simple implementation representing a role identified by a string.
1716
*
1817
* @author Fabien Potencier <[email protected]>
1918
*/

src/Symfony/Component/Security/Core/Role/RoleInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* supported by at least one AccessDecisionManager.
1919
*
2020
* @author Fabien Potencier <[email protected]>
21+
*
22+
* @deprecated The RoleInterface is deprecated since version 3.3 and will be removed in 4.0. Extend the Symfony\Component\Security\Core\Role\Role class instead.
2123
*/
2224
interface RoleInterface
2325
{

src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Security\Guard\Token;
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
15-
use Symfony\Component\Security\Core\Role\RoleInterface;
15+
use Symfony\Component\Security\Core\Role\Role;
1616
use Symfony\Component\Security\Core\User\UserInterface;
1717

1818
/**
@@ -28,9 +28,9 @@ class PostAuthenticationGuardToken extends AbstractToken implements GuardTokenIn
2828
private $providerKey;
2929

3030
/**
31-
* @param UserInterface $user The user!
32-
* @param string $providerKey The provider (firewall) key
33-
* @param RoleInterface[]|string[] $roles An array of roles
31+
* @param UserInterface $user The user!
32+
* @param string $providerKey The provider (firewall) key
33+
* @param (Role|string)[] $roles An array of roles
3434
*
3535
* @throws \InvalidArgumentException
3636
*/

src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Http\Tests\Firewall;
1313

14+
use Symfony\Component\Security\Core\Role\Role;
1415
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
1516
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
1617
use Symfony\Component\Security\Http\SecurityEvents;
@@ -66,7 +67,7 @@ public function testEventIsIgnoredIfUsernameIsNotPassedWithTheRequest()
6667
*/
6768
public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBeFound()
6869
{
69-
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
70+
$token = $this->getToken(array(new Role('the role')));
7071

7172
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
7273
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('_exit'));
@@ -216,7 +217,7 @@ public function testExitUserDoesNotDispatchEventWithStringUser()
216217
*/
217218
public function testSwitchUserIsDisallowed()
218219
{
219-
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
220+
$token = $this->getToken(array(new Role('the role')));
220221

221222
$this->tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue($token));
222223
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
@@ -231,7 +232,7 @@ public function testSwitchUserIsDisallowed()
231232

232233
public function testSwitchUser()
233234
{
234-
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
235+
$token = $this->getToken(array(new Role('the role')));
235236
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
236237
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
237238

@@ -261,7 +262,7 @@ public function testSwitchUser()
261262

262263
public function testSwitchUserKeepsOtherQueryStringParameters()
263264
{
264-
$token = $this->getToken(array($this->getMock('Symfony\Component\Security\Core\Role\RoleInterface')));
265+
$token = $this->getToken(array(new Role('the role')));
265266
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
266267
$user->expects($this->any())->method('getRoles')->will($this->returnValue(array()));
267268

0 commit comments

Comments
 (0)