feat(symfony): expose voter reasons - #8448
Open
nozarashi20 wants to merge 1 commit into
Open
Conversation
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.
This PR includes Symfony voter reasons in denied HTTP and GraphQL responses when
%kernel.debug%is enabled. It captures a newAccessDecisionfor eachis_granted()call without changing the result of the security expression.An explicit security message configured on the operation still takes priority. If no message is configured, API Platform uses the voter message in debug mode and falls back to
Access Denied.when no voter message is available. Voter reasons are never exposed when debug mode is disabled.ResourceAccessCheckerInterfaceis unchanged. Existing custom resource access checkers continue to work and useAccess Denied.unless they provide a captured message. Custom and decorated Symfony authorization checkers continue to determine whether access is granted.The
mcp/sdkdevelopment constraint now allows^0.7, as required by the current version ofsymfony/mcp-bundle. Without this change, Composer cannot install the dependencies.Tests are split by responsibility:
AccessDecisionCapturingAuthorizationCheckerTestchecks that each authorization check gets its own decision and that messages contain the reasons added by the voters.ResourceAccessCheckerTestchecks&&,||, negation, failures outsideis_granted(), and clearing the previous voter message before evaluating another expression.AccessCheckerProviderTestchecks configured messages, debug and non-debug behavior, HTTP and GraphQL exceptions, and compatibility with custom resource access checkers.