Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa7d3d0

Browse filesBrowse files
committed
[Security] Remove dead code about ROLE_PREVIOUS_ADMIN
1 parent c63faff commit fa7d3d0
Copy full SHA for fa7d3d0

File tree

3 files changed

+2
-7
lines changed
Filter options

3 files changed

+2
-7
lines changed

‎src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testCollectSwitchUserToken()
103103
$adminToken = new UsernamePasswordToken(new InMemoryUser('yceruto', 'P4$$w0rD', ['ROLE_ADMIN']), 'provider', ['ROLE_ADMIN']);
104104

105105
$tokenStorage = new TokenStorage();
106-
$tokenStorage->setToken(new SwitchUserToken(new InMemoryUser('hhamon', 'P4$$w0rD', ['ROLE_USER', 'ROLE_PREVIOUS_ADMIN']), 'provider', ['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $adminToken));
106+
$tokenStorage->setToken(new SwitchUserToken(new InMemoryUser('hhamon', 'P4$$w0rD', ['ROLE_USER', 'ROLE_KOALA']), 'provider', ['ROLE_USER', 'ROLE_KOALA'], $adminToken));
107107

108108
$collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy(), null, null, null, null, true);
109109
$collector->collect(new Request(), new Response());
@@ -115,7 +115,7 @@ public function testCollectSwitchUserToken()
115115
$this->assertSame('yceruto', $collector->getImpersonatorUser());
116116
$this->assertSame(SwitchUserToken::class, $collector->getTokenClass()->getValue());
117117
$this->assertTrue($collector->supportsRoleHierarchy());
118-
$this->assertSame(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $collector->getRoles()->getValue(true));
118+
$this->assertSame(['ROLE_USER', 'ROLE_KOALA'], $collector->getRoles()->getValue(true));
119119
$this->assertSame([], $collector->getInheritedRoles()->getValue(true));
120120
$this->assertSame('hhamon', $collector->getUser());
121121
}

‎src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/ContextListener.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa
302302

303303
$userRoles = array_map('strval', (array) $refreshedUser->getRoles());
304304

305-
if ($refreshedToken instanceof SwitchUserToken) {
306-
$userRoles[] = 'ROLE_PREVIOUS_ADMIN';
307-
}
308-
309305
if (
310306
\count($userRoles) !== \count($refreshedToken->getRoleNames())
311307
|| \count($userRoles) !== \count(array_intersect($userRoles, $refreshedToken->getRoleNames()))

‎src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ private function attemptSwitchUser(Request $request, string $username): ?TokenIn
180180
$this->userChecker->checkPostAuth($user);
181181

182182
$roles = $user->getRoles();
183-
$roles[] = 'ROLE_PREVIOUS_ADMIN';
184183
$originatedFromUri = str_replace('/&', '/?', preg_replace('#[&?]'.$this->usernameParameter.'=[^&]*#', '', $request->getRequestUri()));
185184
$token = new SwitchUserToken($user, $this->firewallName, $roles, $token, $originatedFromUri);
186185

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.