Skip to content

Commit a23e15b

Browse files
committed
Rebase for 6.3
1 parent 5e4733b commit a23e15b

35 files changed

+137
-98
lines changed

UPGRADE-6.4.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ Security
136136
* [BC break] `UserValueResolver` no longer implements `ArgumentValueResolverInterface`
137137
* [BC break] Make `PersistentToken` immutable
138138
* Deprecate accepting only `DateTime` for `TokenProviderInterface::updateToken()`, use `DateTimeInterface` instead
139+
* Add method `getDecision()` to `AccessDecisionStrategyInterface`
140+
* Deprecate `AccessDecisionStrategyInterface::decide()` in favor of `AccessDecisionStrategyInterface::getDecision()`
141+
* Add method `getVote()` to `VoterInterface`
142+
* Deprecate `VoterInterface::vote()` in favor of `AccessDecisionStrategyInterface::getVote()`
143+
* Deprecate returning `bool` from `Voter::voteOnAttribute()` (it must return a `Vote`)
144+
* Add method `getDecision()` to `AccessDecisionManagerInterface`
145+
* Deprecate `AccessDecisionManagerInterface::decide()` in favor of `AccessDecisionManagerInterface::getDecision()`
146+
* Add method `getDecision()` to `AuthorizationCheckerInterface`
147+
* Add methods `setAccessDecision()` and `getAccessDecision()` to `AccessDeniedException`
148+
* Add method `getDecision()` to `Security`
139149

140150
SecurityBundle
141151
--------------

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
2929
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
3030
use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter;
31+
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
3132
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
3233
use Symfony\Component\Security\Core\Role\RoleHierarchy;
3334
use Symfony\Component\Security\Core\User\InMemoryUser;
@@ -434,4 +435,8 @@ final class DummyVoter implements VoterInterface
434435
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
435436
{
436437
}
438+
439+
public function getVote(TokenInterface $token, mixed $subject, array $attributes): Vote
440+
{
441+
}
437442
}

src/Symfony/Bundle/SecurityBundle/Tests/EventListener/VoteListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testOnVoterVoteLegacy()
5050
$traceableAccessDecisionManager = $this
5151
->getMockBuilder(TraceableAccessDecisionManager::class)
5252
->disableOriginalConstructor()
53-
->setMethods(['addVoterVote'])
53+
->onlyMethods(['addVoterVote'])
5454
->getMock();
5555

5656
$traceableAccessDecisionManager

src/Symfony/Component/Security/Core/Authorization/AccessDecision.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,12 @@
2222
*/
2323
final class AccessDecision
2424
{
25-
/** @var int One of the VoterInterface::ACCESS_* constants */
26-
private int $access;
27-
28-
/** @var Vote[] */
29-
private array $votes = [];
30-
3125
/**
3226
* @param int $access One of the VoterInterface::ACCESS_* constants
3327
* @param Vote[] $votes
3428
*/
35-
private function __construct(int $access, array $votes = [])
29+
private function __construct(private readonly int $access, private readonly array $votes = [])
3630
{
37-
$this->access = $access;
38-
$this->votes = $votes;
3931
}
4032

4133
public function getAccess(): int
@@ -111,8 +103,6 @@ public function getDeniedVotes(): array
111103
*/
112104
private function getVotesByAccess(int $access): array
113105
{
114-
return array_filter($this->votes, static function (Vote $vote) use ($access): bool {
115-
return $vote->getAccess() === $access;
116-
});
106+
return array_filter($this->votes, static fn (Vote $vote): bool => $vote->getAccess() === $access);
117107
}
118108
}

src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
*/
2828
final class AccessDecisionManager implements AccessDecisionManagerInterface
2929
{
30-
private const VALID_VOTES = [
31-
VoterInterface::ACCESS_GRANTED => true,
32-
VoterInterface::ACCESS_DENIED => true,
33-
VoterInterface::ACCESS_ABSTAIN => true,
34-
];
35-
3630
private iterable $voters;
3731
private array $votersCacheAttributes = [];
3832
private array $votersCacheObject = [];
@@ -70,11 +64,11 @@ public function getDecision(TokenInterface $token, array $attributes, mixed $obj
7064
/**
7165
* @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array
7266
*
73-
* @deprecated since Symfony 6.2, use {@see getDecision()} instead.
67+
* @deprecated since Symfony 6.3, use {@see getDecision()} instead.
7468
*/
7569
public function decide(TokenInterface $token, array $attributes, mixed $object = null, bool $allowMultipleAttributes = false): bool
7670
{
77-
trigger_deprecation('symfony/security-core', '6.2', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
71+
trigger_deprecation('symfony/security-core', '6.3', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
7872

7973
// Special case for AccessListener, do not remove the right side of the condition before 6.0
8074
if (\count($attributes) > 1 && !$allowMultipleAttributes) {

src/Symfony/Component/Security/Core/Authorization/AccessDecisionManagerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface AccessDecisionManagerInterface
2828
* @param array $attributes An array of attributes associated with the method being invoked
2929
* @param mixed $object The object to secure
3030
*
31-
* @deprecated since Symfony 6.2, use {@see getDecision()} instead.
31+
* @deprecated since Symfony 6.3, use {@see getDecision()} instead.
3232
*/
3333
public function decide(TokenInterface $token, array $attributes, mixed $object = null): bool;
3434
}

src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final public function getDecision($attribute, $subject = null): AccessDecision
5151
}
5252

5353
if (!method_exists($this->accessDecisionManager, 'getDecision')) {
54-
trigger_deprecation('symfony/security-core', '6.2', 'Not implementing "%s::getDecision()" method is deprecated, and would be required in 7.0.', \get_class($this->accessDecisionManager));
54+
trigger_deprecation('symfony/security-core', '6.3', 'Not implementing "%s::getDecision()" method is deprecated, and would be required in 7.0.', \get_class($this->accessDecisionManager));
5555

5656
return $this->accessDecisionManager->decide($token, [$attribute], $subject) ? AccessDecision::createGranted() : AccessDecision::createDenied();
5757
}

src/Symfony/Component/Security/Core/Authorization/Strategy/AccessDecisionStrategyInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface AccessDecisionStrategyInterface
2525
/**
2626
* @param \Traversable<int> $results
2727
*
28-
* @deprecated since Symfony 6.2, use {@see getDecision()} instead.
28+
* @deprecated since Symfony 6.3, use {@see getDecision()} instead.
2929
*/
3030
public function decide(\Traversable $results): bool;
3131
}

src/Symfony/Component/Security/Core/Authorization/Strategy/AffirmativeStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getDecision(\Traversable $votes): AccessDecision
6363

6464
public function decide(\Traversable $results): bool
6565
{
66-
trigger_deprecation('symfony/security-core', '6.2', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
66+
trigger_deprecation('symfony/security-core', '6.3', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
6767

6868
$deny = 0;
6969
foreach ($results as $result) {

src/Symfony/Component/Security/Core/Authorization/Strategy/ConsensusStrategy.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public function __construct(bool $allowIfAllAbstainDecisions = false, bool $allo
4444
$this->allowIfEqualGrantedDeniedDecisions = $allowIfEqualGrantedDeniedDecisions;
4545
}
4646

47-
/**
48-
* {@inheritdoc}
49-
*/
5047
public function getDecision(\Traversable $votes): AccessDecision
5148
{
5249
$currentVotes = [];
@@ -84,12 +81,9 @@ public function getDecision(\Traversable $votes): AccessDecision
8481
;
8582
}
8683

87-
/**
88-
* {@inheritdoc}
89-
*/
9084
public function decide(\Traversable $results): bool
9185
{
92-
trigger_deprecation('symfony/security-core', '6.2', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
86+
trigger_deprecation('symfony/security-core', '6.3', 'Method "%s::decide()" has been deprecated, use "%s::getDecision()" instead.', __CLASS__, __CLASS__);
9387

9488
$grant = 0;
9589
$deny = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy