[4.x] Fix #[Authorize] attribute doesnt trigger component exception hook - #10483
Closed
ghabriel25 wants to merge 2 commits into
Closed
[4.x] Fix #[Authorize] attribute doesnt trigger component exception hook#10483ghabriel25 wants to merge 2 commits into
#[Authorize] attribute doesnt trigger component exception hook#10483ghabriel25 wants to merge 2 commits into
Conversation
ghabriel25
marked this pull request as draft
August 3, 2026 08:03
ghabriel25
force-pushed
the
fix/authorize-attribute-clean
branch
2 times, most recently
from
August 3, 2026 08:20
49afa5b to
b5cfa77
Compare
ghabriel25
force-pushed
the
fix/authorize-attribute-clean
branch
from
August 3, 2026 08:32
b5cfa77 to
8b89bcc
Compare
ghabriel25
marked this pull request as ready for review
August 3, 2026 08:41
Contributor
Author
|
Going to close this as I've found more simple solution rather than exposing new public method to the component. I'll submit the PR later |
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.
Scenario
When using
#[Authorize]attribute to perform authorization as pre-method execution. It doesnt trigger the componentexception()hook.Problem
Attribute
call()handled bySupportAttributes::call()which is running before the actual method get called so any exception thrown will not get handled by component exception hook.Solution
Delegate authorization to
HandlesAuthorizationtrait and insideBaseAuthorize::call(), wrap the component before performing the authorization from that trait. This way, any exception thrown can be catched from componentexception()hook. All method parameters resolution handled just like before.Whats Changed
HandlesAuthorizationtraitAuthorizesRequeststrait fromComponenttoHandlesAuthorizationtrait#[Authorize]attribute or$this->authorize()Fix: #10410