Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractRestfulController's onDispatch - set action/method parameter prior dispatch #3

Open
2 tasks done
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open
2 tasks done

Comments

@weierophinney
Copy link
Member

AbstractRestfulController: Set action/method parameter prior dispatch

I've wrote an authentication module to authenticate users and setup authentication chains..
It registers a listener to the MvcEvent::EVENT_DISPATCH@ AbstractActionController
The authenticator can either allow or kill the request depending on the configuration. We can dictate, in the configuration, the list of controllers that requires authentication as well as indicating which controller's action to require authentication.

The above would fail if we register the listener @ AbstractController as the action parameter is not yet set when the callback is fired. It is set only after processing the request (see AbstractRestfulController.php) or if the action is already registered by the router.

Our target is to distinguish between various "actions" the restful controller is mapping to, to filter unauthenticated users on a per-action or per-restful-method basis.
While it is possible to achieve the above by embedding additional checkers in the header of each method, we are hoping to achieve it by registering a listener for convenience.

It boils down to setting an additional parameter (e.g. method) to indicate which method will fire, and to authenticate, that parameter must be readable before the request is dispatched by the restful controller.

I have not yet dived into the internals, but what about an early dispatch listener that will set the method parameter according to the mappings of AbstractRestfulController?


Originally posted by @alichry at zendframework/zend-mvc#314

@alichry
Copy link

alichry commented Jul 4, 2020

Hello,

Is it possible to move the functionality of determining the target method from AbstractRestfulController's onDispatch to somewhere prior dispatch? I've provided a fix for this, specific for my purpose, using EigenRestfulController

I would appreciate a contributor's input on this, would it be possible to perform the mapping during the MVC lifecycle? Maybe adding this as a milestone for v4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants