Skip to content

Commit a16cb35

Browse files
authored
feat(symfony): Remove deprecated $exceptionOnNoToken parameter in ResourceAccessChecker (#4905)
1 parent b80b5b0 commit a16cb35

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
=======
33

4+
## 3.0.0-rc.3
5+
6+
* Symfony: removed the `$exceptionOnNoToken` parameter in `ResourceAccessChecker::__construct()` (#4900)
7+
48
## 3.0.0-beta.2
59

610
* ExpressionLanguage: deprecated class `ApiPlatform\Symfony\Security\ExpressionLanguage` has been removed in favor of `Symfony\Component\Security\Core\Authorization\ExpressionLanguage`.

src/Symfony/Security/ResourceAccessChecker.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
final class ResourceAccessChecker implements ResourceAccessCheckerInterface
3030
{
31-
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)
31+
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)
3232
{
3333
}
3434

@@ -38,13 +38,7 @@ public function isGranted(string $resourceClass, string $expression, array $extr
3838
throw new \LogicException('The "symfony/security" library must be installed to use the "security" attribute.');
3939
}
4040
if (null === $token = $this->tokenStorage->getToken()) {
41-
if ($this->exceptionOnNoToken) {
42-
throw new \LogicException('The current token must be set to use the "security" attribute (is the URL behind a firewall?).');
43-
}
44-
45-
if (class_exists(NullToken::class)) {
46-
$token = new NullToken();
47-
}
41+
$token = new NullToken();
4842
}
4943
if (null === $this->expressionLanguage) {
5044
throw new \LogicException('The "symfony/expression-language" library must be installed to use the "security" attribute.');

0 commit comments

Comments
 (0)