File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Security \Core \Role ;
13+
14+ /**
15+ * Allows migrating session payloads from v4.
16+ *
17+ * @internal
18+ */
19+ class Role
20+ {
21+ private $ role ;
22+
23+ private function __construct ()
24+ {
25+ }
26+
27+ public function __toString (): string
28+ {
29+ return $ this ->role ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Security \Core \Role ;
13+
14+ /**
15+ * Allows migrating session payloads from v4.
16+ *
17+ * @internal
18+ */
19+ class SwitchUserRole extends Role
20+ {
21+ private $ deprecationTriggered ;
22+ private $ source ;
23+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Security \Core \Tests \Role ;
13+
14+ use PHPUnit \Framework \TestCase ;
15+ use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
16+
17+ class LegacyRoleTest extends TestCase
18+ {
19+ public function testPayloadFromV4CanBeUnserialized ()
20+ {
21+ $ 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";}}}} ' ;
22+
23+ $ token = unserialize ($ serialized );
24+
25+ $ this ->assertInstanceOf (UsernamePasswordToken::class, $ token );
26+ $ this ->assertSame (['ROLE_USER ' ], $ token ->getRoleNames ());
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments