From 9541def76d1e6a637f6632002b321b6284c93f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20J=2E=20Garc=C3=ADa=20Lagar?= Date: Wed, 29 Dec 2021 19:20:48 +0100 Subject: [PATCH] Remove role classes that allow migrating session payloads from v4 --- .../Component/Security/Core/Role/Role.php | 31 ------------------- .../Security/Core/Role/SwitchUserRole.php | 23 -------------- .../Core/Tests/Role/LegacyRoleTest.php | 28 ----------------- 3 files changed, 82 deletions(-) delete mode 100644 src/Symfony/Component/Security/Core/Role/Role.php delete mode 100644 src/Symfony/Component/Security/Core/Role/SwitchUserRole.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Role/LegacyRoleTest.php diff --git a/src/Symfony/Component/Security/Core/Role/Role.php b/src/Symfony/Component/Security/Core/Role/Role.php deleted file mode 100644 index 374eb59fe85ca..0000000000000 --- a/src/Symfony/Component/Security/Core/Role/Role.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Role; - -/** - * Allows migrating session payloads from v4. - * - * @internal - */ -class Role -{ - private $role; - - private function __construct() - { - } - - public function __toString(): string - { - return $this->role; - } -} diff --git a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php b/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php deleted file mode 100644 index 6a29fb4daa29b..0000000000000 --- a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Role; - -/** - * Allows migrating session payloads from v4. - * - * @internal - */ -class SwitchUserRole extends Role -{ - private $deprecationTriggered; - private $source; -} diff --git a/src/Symfony/Component/Security/Core/Tests/Role/LegacyRoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/LegacyRoleTest.php deleted file mode 100644 index 44c9566720b89..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Role/LegacyRoleTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Role; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; - -class LegacyRoleTest extends TestCase -{ - public function testPayloadFromV4CanBeUnserialized() - { - $serialized = 'C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":236:{a:3:{i:0;N;i:1;s:4:"main";i:2;a:5:{i:0;s:2:"sf";i:1;b:1;i:2;a:1:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"Symfony\Component\Security\Core\Role\Role'."\0".'role'."\0".'";s:9:"ROLE_USER";}}i:3;a:0:{}i:4;a:1:{i:0;s:9:"ROLE_USER";}}}}'; - - $token = unserialize($serialized); - - $this->assertInstanceOf(UsernamePasswordToken::class, $token); - $this->assertSame(['ROLE_USER'], $token->getRoleNames()); - } -}