8000 [Security] Allow AuthorizationChecker::isGrantedForUser to check for guest permissions by aschempp · Pull Request #61938 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow to vote on guest user
  • Loading branch information
aschempp committed Oct 27, 2025
commit 189cb05aa6917b95d7c8b03562d324bba54fd995
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ final public function isGranted(mixed $attribute, mixed $subject = null, ?Access
}
}

final public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
final public function isGrantedForUser(UserInterface|null $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
{
$token = new class($user->getRoles()) extends AbstractToken implements OfflineTokenInterface {};
$token->setUser($user);
$token = new class($user?->getRoles() ?? []) extends AbstractToken implements OfflineTokenInterface {};

if ($user) {
$token->setUser($user);
}

$this->tokenStack[] = $token;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ interface UserAuthorizationCheckerInterface
* @param mixed $attribute A single attribute to vote on (can be of any type, string and instance of Expression are supported by the core)
* @param AccessDecision|null $accessDecision Should be used to explain the decision
*/
public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool;
public function isGrantedForUser(UserInterface|null $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool;
}
0