Allow Closure for requireAuthorizationCheck config option#322
Merged
dereuromark merged 1 commit into3.nextfrom Mar 29, 2026
Merged
Allow Closure for requireAuthorizationCheck config option#322dereuromark merged 1 commit into3.nextfrom
dereuromark merged 1 commit into3.nextfrom
Conversation
dereuromark
commented
Mar 29, 2026
Contributor
|
As this is a new feature shouldn't this be added to 3.next? |
Member
Author
|
For these small satellite repos its sometimes overkill, since this would be a simple minor release without all the branch switching/merging. |
feea565 to
2cc9135
Compare
2cc9135 to
fbcd4dd
Compare
ADmad
approved these changes
Mar 29, 2026
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
This PR adds support for a callable in the
requireAuthorizationCheckmiddleware configuration option. Currently, this option only accepts a boolean value, but applications often need to conditionally skip authorization checks based on the request path or other request attributes.Use Case
When integrating third-party plugins that provide their own admin panels (e.g., queue management dashboards), these plugins may manage authorization independently. The host application needs a way to skip the middleware's authorization check for these specific routes without disabling it globally.
Before this PR, applications had to wrap the middleware in a custom closure:
After this PR, the same can be achieved cleanly:
Changes
AuthorizationMiddleware::process()to check ifrequireAuthorizationCheckis callable and invoke it with the requesttrue(requires authorization check)false(skips authorization check)Backwards Compatibility
This change is fully backwards compatible. The existing boolean behavior is preserved - the callable is only invoked if the config value is callable.