Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

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

Open
2 tasks done
alichry opened this issue Aug 8, 2019 · 1 comment
Open
2 tasks done

Comments

@alichry
Copy link

alichry commented Aug 8, 2019

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?

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-mvc; a new issue has been opened at laminas/laminas-mvc#3.

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

No branches or pull requests

2 participants