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

Skip to content

Commit be387ed

Browse files
committed
[Security] remove deprecated features
1 parent b777f42 commit be387ed

15 files changed

+37
-224
lines changed

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
CHANGELOG
22
=========
33

4+
4.0.0
5+
-----
6+
7+
* The `AbstractFormLoginAuthenticator::onAuthenticationSuccess()` was removed.
8+
You should implement this method yourself in your concrete authenticator.
9+
* removed the `AccessDecisionManager::setVoters()` method
10+
* removed the `RoleInterface`
11+
* added a sixth `$context` argument to the `LogoutUrlGenerator::registerListener()`
12+
method
13+
414
3.3.0
515
-----
616

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

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

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

14-
use Symfony\Component\Security\Core\Role\RoleInterface;
1514
use Symfony\Component\Security\Core\Role\Role;
1615
use Symfony\Component\Security\Core\User\UserInterface;
1716
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
@@ -33,7 +32,7 @@ abstract class AbstractToken implements TokenInterface
3332
/**
3433
* Constructor.
3534
*
36-
* @param (RoleInterface|string)[] $roles An array of roles
35+
* @param (Role|string)[] $roles An array of roles
3736
*
3837
* @throws \InvalidArgumentException
3938
*/
@@ -42,8 +41,8 @@ public function __construct(array $roles = array())
4241
foreach ($roles as $role) {
4342
if (is_string($role)) {
4443
$role = new Role($role);
45-
} elseif (!$role instanceof RoleInterface) {
46-
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, or RoleInterface instances, but got %s.', gettype($role)));
44+
} elseif (!$role instanceof Role) {
45+
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, or Role instances, but got %s.', gettype($role)));
4746
}
4847

4948
$this->roles[] = $role;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class PreAuthenticatedToken extends AbstractToken
2424
/**
2525
* Constructor.
2626
*
27-
* @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
28-
* @param mixed $credentials The user credentials
29-
* @param string $providerKey The provider key
30-
* @param (RoleInterface|string)[] $roles An array of roles
27+
* @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
28+
* @param mixed $credentials The user credentials
29+
* @param string $providerKey The provider key
30+
* @param (Role|string)[] $roles An array of roles
3131
*/
3232
public function __construct($user, $credentials, $providerKey, array $roles = array())
3333
{

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

Lines changed: 2 additions & 2 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
* TokenInterface is the interface for the user authentication information.
@@ -33,7 +33,7 @@ public function __toString();
3333
/**
3434
* Returns the user roles.
3535
*
36-
* @return RoleInterface[] An array of RoleInterface instances
36+
* @return Role[] An array of Role instances
3737
*/
3838
public function getRoles();
3939

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class UsernamePasswordToken extends AbstractToken
2424
/**
2525
* Constructor.
2626
*
27-
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
28-
* @param string $credentials This usually is the password of the user
29-
* @param string $providerKey The provider key
30-
* @param (RoleInterface|string)[] $roles An array of roles
27+
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
28+
* @param string $credentials This usually is the password of the user
29+
* @param string $providerKey The provider key
30+
* @param (Role|string)[] $roles An array of roles
3131
*
3232
* @throws \InvalidArgumentException
3333
*/

src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,6 @@ public function __construct($voters = array(), $strategy = self::STRATEGY_AFFIRM
5252
$this->allowIfEqualGrantedDeniedDecisions = (bool) $allowIfEqualGrantedDeniedDecisions;
5353
}
5454

55-
/**
56-
* Configures the voters.
57-
*
58-
* @param VoterInterface[] $voters An array of VoterInterface instances
59-
*
60-
* @deprecated since version 3.3, to be removed in 4.0. Pass the voters to the constructor instead.
61-
*/
62-
public function setVoters(array $voters)
63-
{
64-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Pass the voters to the constructor instead.', __METHOD__), E_USER_DEPRECATED);
65-
66-
$this->voters = $voters;
67-
}
68-
6955
/**
7056
* {@inheritdoc}
7157
*/

src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,6 @@ public function decide(TokenInterface $token, array $attributes, $object = null)
6060
return $result;
6161
}
6262

63-
/**
64-
* {@inheritdoc}
65-
*
66-
* @deprecated since version 3.3, to be removed in 4.0. Pass voters to the decorated AccessDecisionManager instead.
67-
*/
68-
public function setVoters(array $voters)
69-
{
70-
@trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Pass voters to the decorated AccessDecisionManager instead.', __METHOD__), E_USER_DEPRECATED);
71-
72-
if (!method_exists($this->manager, 'setVoters')) {
73-
return;
74-
}
75-
76-
$this->voters = $voters;
77-
$this->manager->setVoters($voters);
78-
}
79-
8063
/**
8164
* @return string
8265
*/

src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Authorization\Voter;
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15-
use Symfony\Component\Security\Core\Role\RoleInterface;
15+
use Symfony\Component\Security\Core\Role\Role;
1616

1717
/**
1818
* RoleVoter votes if any attribute starts with a given prefix.
@@ -42,7 +42,7 @@ public function vote(TokenInterface $token, $subject, array $attributes)
4242
$roles = $this->extractRoles($token);
4343

4444
foreach ($attributes as $attribute) {
45-
if ($attribute instanceof RoleInterface) {
45+
if ($attribute instanceof Role) {
4646
$attribute = $attribute->getRole();
4747
}
4848

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Fabien Potencier <[email protected]>
1818
*/
19-
class Role implements RoleInterface
19+
class Role
2020
{
2121
private $role;
2222

@@ -31,7 +31,9 @@ public function __construct($role)
3131
}
3232

3333
/**
34-
* {@inheritdoc}
34+
* Returns a string representation of the role.
35+
*
36+
* @return string
3537
*/
3638
public function getRole()
3739
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ interface RoleHierarchyInterface
2424
* Reachable roles are the roles directly assigned but also all roles that
2525
* are transitively reachable from them in the role hierarchy.
2626
*
27-
* @param RoleInterface[] $roles An array of directly assigned roles
27+
* @param Role[] $roles An array of directly assigned roles
2828
*
29-
* @return RoleInterface[] An array of all reachable roles
29+
* @return Role[] An array of all reachable roles
3030
*/
3131
public function getReachableRoles(array $roles);
3232
}

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Security/Guard/Authenticator/AbstractFormLoginAuthenticator.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
1616
use Symfony\Component\HttpFoundation\RedirectResponse;
1717
use Symfony\Component\HttpFoundation\Request;
18-
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1918
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2019
use Symfony\Component\Security\Core\Security;
2120
use Symfony\Component\Security\Http\Util\TargetPathTrait;
@@ -55,38 +54,6 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
5554
return new RedirectResponse($url);
5655
}
5756

58-
/**
59-
* Override to change what happens after successful authentication.
60-
*
61-
* @param Request $request
62-
* @param TokenInterface $token
63-
* @param string $providerKey
64-
*
65-
* @return RedirectResponse
66-
*/
67-
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
68-
{
69-
@trigger_error(sprintf('The AbstractFormLoginAuthenticator::onAuthenticationSuccess() implementation was deprecated in Symfony 3.1 and will be removed in Symfony 4.0. You should implement this method yourself in %s and remove getDefaultSuccessRedirectUrl().', get_class($this)), E_USER_DEPRECATED);
70-
71-
if (!method_exists($this, 'getDefaultSuccessRedirectUrl')) {
72-
throw new \Exception(sprintf('You must implement onAuthenticationSuccess() or getDefaultSuccessRedirectUrl() in %s.', get_class($this)));
73-
}
74-
75-
$targetPath = null;
76-
77-
// if the user hit a secure page and start() was called, this was
78-
// the URL they were on, and probably where you want to redirect to
79-
if ($request->getSession() instanceof SessionInterface) {
80-
$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
81-
}
82-
83-
if (!$targetPath) {
84-
$targetPath = $this->getDefaultSuccessRedirectUrl();
85-
}
86-
87-
return new RedirectResponse($targetPath);
88-
}
89-
9057
public function supportsRememberMe()
9158
{
9259
return true;

src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1617
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718
use Symfony\Component\Security\Core\User\UserInterface;
1819
use Symfony\Component\Security\Core\User\UserProviderInterface;
@@ -51,59 +52,6 @@ public function testAuthenticationFailureWithSession()
5152
$this->assertEquals(self::LOGIN_URL, $failureResponse->getTargetUrl());
5253
}
5354

54-
/**
55-
* @group legacy
56-
*/
57-
public function testAuthenticationSuccessWithoutSession()
58-
{
59-
$token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')
60-
->disableOriginalConstructor()
61-
->getMock();
62-
63-
$redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithoutSession, $token, 'providerkey');
64-
65-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $redirectResponse);
66-
$this->assertEquals(self::DEFAULT_SUCCESS_URL, $redirectResponse->getTargetUrl());
67-
}
68-
69-
/**
70-
* @group legacy
71-
*/
72-
public function testAuthenticationSuccessWithSessionButEmpty()
73-
{
74-
$token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')
75-
->disableOriginalConstructor()
76-
->getMock();
77-
$this->requestWithSession->getSession()
78-
->expects($this->once())
79-
->method('get')
80-
->will($this->returnValue(null));
81-
82-
$redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey');
83-
84-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $redirectResponse);
85-
$this->assertEquals(self::DEFAULT_SUCCESS_URL, $redirectResponse->getTargetUrl());
86-
}
87-
88-
/**
89-
* @group legacy
90-
*/
91-
public function testAuthenticationSuccessWithSessionAndTarget()
92-
{
93-
$token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')
94-
->disableOriginalConstructor()
95-
->getMock();
96-
$this->requestWithSession->getSession()
97-
->expects($this->once())
98-
->method('get')
99-
->will($this->returnValue(self::CUSTOM_SUCCESS_URL));
100-
101-
$redirectResponse = $this->authenticator->onAuthenticationSuccess($this->requestWithSession, $token, 'providerkey');
102-
103-
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $redirectResponse);
104-
$this->assertEquals(self::CUSTOM_SUCCESS_URL, $redirectResponse->getTargetUrl());
105-
}
106-
10755
public function testRememberMe()
10856
{
10957
$doSupport = $this->authenticator->supportsRememberMe();
@@ -156,6 +104,10 @@ class TestFormLoginAuthenticator extends AbstractFormLoginAuthenticator
156104
private $loginUrl;
157105
private $defaultSuccessRedirectUrl;
158106

107+
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
108+
{
109+
}
110+
159111
/**
160112
* @param mixed $defaultSuccessRedirectUrl
161113
*

0 commit comments

Comments
 (0)