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

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

Open
@alichry

Description

@alichry

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions