8000 feature #12956 Added documentation for the priority access decision s… · symfony/symfony-docs@2754e72 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2754e72

Browse files
committed
feature #12956 Added documentation for the priority access decision strategy (aschempp)
This PR was squashed before being merged into the master branch (closes #12956). Discussion ---------- Added documentation for the priority access decision strategy fixes #12830 Commits ------- c903f4a Added documentation for the priority access decision strategy
2 parents 2d57b66 + c903f4a commit 2754e72

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

components/security/authorization.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,21 @@ recognizes several strategies:
4949
``unanimous``
5050
only grant access if none of the voters has denied access;
5151

52+
``priority``
53+
grants or denies access by the first voter that does not abstain;
54+
55+
.. versionadded:: 5.1
56+
57+
The priority version strategy was introduced in Symfony 5.1.
58+
5259
Usage of the available options in detail::
5360

5461
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
5562

5663
// instances of Symfony\Component\Security\Core\Authorization\Voter\VoterInterface
5764
$voters = [...];
5865

59-
// one of "affirmative", "consensus", "unanimous"
66+
// one of "affirmative", "consensus", "unanimous", "priority"
6067
$strategy = ...;
6168

6269
// whether or not to grant access when all voters abstain
@@ -256,4 +263,3 @@ decision manager::
256263
if (!$authorizationChecker->isGranted('ROLE_ADMIN')) {
257264
throw new AccessDeniedException();
258265
}
259-

security/voters.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ uses the authorization checker), or by
2626

2727
Ultimately, Symfony takes the responses from all voters and makes the final
2828
decision (to allow or deny access to the resource) according to the strategy defined
29-
in the application, which can be: affirmative, consensus or unanimous.
29+
in the application, which can be: affirmative, consensus, unanimous or priority.
3030

3131
For more information take a look at
3232
:ref:`the section about access decision managers <components-security-access-decision-manager>`.
@@ -262,7 +262,7 @@ checks if the user is a member of the site and a second one that checks if the u
262262
is older than 18.
263263

264264
To handle these cases, the access decision manager uses an access decision
265-
strategy. You can configure this to suit your needs. There are three
265+
strategy. You can configure this to suit your needs. There are four
266266
strategies available:
267267

268268
``affirmative`` (default)
@@ -274,7 +274,16 @@ strategies available:
274274
``unanimous``
275275
This only grants access if there is no voter denying access. If all voters
276276
abstained from voting, the decision is based on the ``allow_if_all_abstain``
277-
config option (which defaults to ``false``).
277+
config option (which defaults to ``false``);
278+
279+
``priority``
280+
This grants or denies access by the first voter that does not abstain,
281+
based on their service priority;
282+
283+
.. versionadded:: 5.1
284+
285+
The priority version strategy was introduced in Symfony 5.1.
286+
278287

279288
In the above scenario, both voters should grant access in order to grant access
280289
to the user to read the post. In this case, the default strategy is no longer

0 commit comments

Comments
 (0)
0