Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
=======

## 3.0.0-rc.3

* Symfony: removed the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)

## 3.0.0-beta.2

* ExpressionLanguage: deprecated class `ApiPlatform\Symfony\Security\ExpressionLanguage` has been removed in favor of `Symfony\Component\Security\Core\Authorization\ExpressionLanguage`.
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Security/ResourceAccessChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
final class ResourceAccessChecker implements ResourceAccessCheckerInterface
{
public function __construct(private readonly ?ExpressionLanguage $expressionLanguage = null, private readonly ?AuthenticationTrustResolverInterface $authenticationTrustResolver = null, private readonly ?RoleHierarchyInterface $roleHierarchy = null, private readonly ?TokenStorageInterface $tokenStorage = null, private readonly ?AuthorizationCheckerInterface $authorizationChecker = null, private readonly bool $exceptionOnNoToken = true)
public function __construct(private readonly ?ExpressionLanguage $expressionLanguage = null, private readonly ?AuthenticationTrustResolverInterface $authenticationTrustResolver = null, private readonly ?RoleHierarchyInterface $roleHierarchy = null, private readonly ?TokenStorageInterface $tokenStorage = null, private readonly ?AuthorizationCheckerInterface $authorizationChecker = null)
{
}

Expand All @@ -38,13 +38,7 @@ public function isGranted(string $resourceClass, string $expression, array $extr
throw new \LogicException('The "symfony/security" library must be installed to use the "security" attribute.');
}
if (null === $token = $this->tokenStorage->getToken()) {
if ($this->exceptionOnNoToken) {
throw new \LogicException('The current token must be set to use the "security" attribute (is the URL behind a firewall?).');
}

if (class_exists(NullToken::class)) {
$token = new NullToken();
}
$token = new NullToken();
}
if (null === $this->expressionLanguage) {
throw new \LogicException('The "symfony/expression-language" library must be installed to use the "security" attribute.');
Expand Down