You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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?
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 theaction
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 ofAbstractRestfulController
?Originally posted by @alichry at zendframework/zend-mvc#314
The text was updated successfully, but these errors were encountered: