docs(security): document voter decision reasons - #2333
Merged
Conversation
Core PR #8448 (cd67e0b23) adds the access_decision variable to security expressions and AccessDecision::getMessage(); document how a voter's reason reaches the client and that it is gated by kernel.debug. Also add a usage example for ApiPlatform\Metadata\Exception\AccessDeniedException (F22), the class the upgrade guide already points to.
soyuka
force-pushed
the
docs/security-voter-reasons
branch
from
September 13, 2026 06:59
82a5bc5 to
5b825e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
access_decisionvariable (an instance ofSymfony\Component\Security\Core\Authorization\AccessDecision) now available insecurityexpressions,
AccessDecision::getMessage(), and how a Symfony voter's reason (Vote::addReason())reaches the 403 problem response's
detailfield.kernel.debug— it is only surfaced indev/test; inprodthe client gets a generic "Access Denied." unless an explicitsecurityMessageis set. Verified atsrc/State/ErrorProvider.php:89(
$accessDeniedException->getDetail() ?? ($this->debug ? $accessDeniedException->getMessage() : 'Access Denied.'))and the
%kernel.debug%wiring atsrc/Symfony/Bundle/Resources/config/api.php:307.ApiPlatform\Metadata\Exception\AccessDeniedException(throwing it from a state processor with an explicit
detail), giving the upgrade guide's existingdeprecation note (
core/upgrade-guide.md:61-64) somewhere to point to.Ground truth
cd67e0b23, "feat(symfony): expose voter reasons"), verified againstupstream/4.4ofapi-platform/core:ResourceAccessChecker::decide(),AccessCheckerProvider::provide(),ApiPlatform\Symfony\Security\Core\Authorization\ExpressionLanguageProvider(overrides
is_granted()to forwardaccess_decision), andvendor/symfony/security-core'sAccessDecision/Vote/AuthorizationCheckerclasses.4.3), which documents that parameter-level securitythrows
AccessDeniedExceptionrather than silently ignoring the parameter.Page choice
Added to
symfony/security.md, notcore/security.md.core/security.mdis a 13-line stub thatonly redirects to the Symfony/Laravel-specific pages; every other technical detail of this feature
(
is_granted(),ResourceAccessChecker, Symfony'sVoter/VoteAPI,AccessCheckerProvider) isSymfony-only and already lives in
symfony/security.md, right next to the existing "Hooking CustomPermission Checks Using Voters" and "Configuring the Access Control Error Message" sections.
Test plan
npx prettier@3.9.5 --check "**/*.md" --prose-wrap alwayspasses repo-wideapi-platform/coreupstream/4.4source