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

ModuleRouteListener won't Trigger MvcAuthEvents #127

Open
disasterdrop opened this issue Jul 21, 2016 · 3 comments
Open

ModuleRouteListener won't Trigger MvcAuthEvents #127

disasterdrop opened this issue Jul 21, 2016 · 3 comments

Comments

@disasterdrop
Copy link

Hi,

i have updated Apigility today and run in to this behaviour:

The oauth2 authentication rules did not work and everything was outside of authentication and served without checking if user has right Authorization header set.

What i found was that, whe i change this code in module/Application/Module.php

$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);

to

$mvcAuthEvent = new MvcAuthEvent($e, $serviceManager->get('authentication'), $serviceManager->get('authorization'));
$moduleRouteListener = new MvcRouteListener($mvcAuthEvent, $eventManager, $serviceManager->get('authentication'));
$moduleRouteListener->attach($eventManager);

everything is working again.
Was it intended to change it manually, so that you could use your own AuthListener or was it removed for ZF3 purpose?

I'm curious why nobody else was running into this...
And if it's not a bug, is it a valid approach to use the MvcAuthEvent like this?

@Iraecio
Copy link

Iraecio commented Jul 23, 2016

same problem here i updated 23/07

how u use $serviceManager

@disasterdrop
Copy link
Author

@Iraecio
You can access the Service Manager over the MvcEvent with:
$serviceManager = $e->getApplication()->getServiceManager();

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-skeleton; a new issue has been opened at laminas-api-tools/api-tools-skeleton#10.

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

3 participants