Skip to content

Commit 0950773

Browse files
[Security] Unset token roles when serializing it and user implements EquatableInterface
1 parent 306fd3b commit 0950773

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Firewall/ContextListener.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,12 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa
301301
}
302302
}
303303

304-
$userRoles = array_map('strval', $refreshedUser->getRoles());
304+
$refreshedRoles = array_map('strval', $refreshedUser->getRoles());
305+
$originalRoles = $refreshedToken->getRoleNames(); // This comes from cloning the original token, so it still contains the roles of the original user
305306

306307
if (
307-
\count($userRoles) !== \count($refreshedToken->getRoleNames())
308-
|| \count($userRoles) !== \count(array_intersect($userRoles, $refreshedToken->getRoleNames()))
308+
\count($refreshedRoles) !== \count($originalRoles)
309+
|| \count($refreshedRoles) !== \count(array_intersect($refreshedRoles, $originalRoles))
309310
) {
310311
return true;
311312
}

0 commit comments

Comments
 (0)