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
{{ message }}
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
class MyTestController extends AuthController {
...
public function __construct($serverFactory, UserIdProviderInterface $userIdProvider) {
parent::__construct($serverFactory, $userIdProvider);
}
public function onDispatch(\Zend\Mvc\MvcEvent $e) {
$server = call_user_func($this->serverFactory, "oauth");
if (!$server->verifyResourceRequest($this->getOAuth2Request())) {
$response = $server->getResponse();
return $this->getApiProblemResponse($response);
}
return parent::onDispatch($e);
}
...
As my API is RESTful, I would like to use the AbstractRestfulController as base for my controller. Could you please give me a hint/code example, how to secure a controller which extends the AbstractRestfulController? I have not found any useful information so far regarding this topic (and as I'm still quite new to ZF2, there's a lot to learn).
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
Note: forget about this ugly 'onDispatch' call within your controller. Its location should be in a dedicated listener and called from you 'onBootstrap' callback in your module class ;)
Can you please share any code example for injecting the server instance (OAuth2\Server) into controller from its factory and call its methods from actions ?
I've finally managed securing my controller (extending the AuthController class) as mentioned in the documentation ( https://github.com/zfcampus/zf-oauth2#how-to-protect-your-api-using-oauth2 ) :
As my API is RESTful, I would like to use the AbstractRestfulController as base for my controller. Could you please give me a hint/code example, how to secure a controller which extends the AbstractRestfulController? I have not found any useful information so far regarding this topic (and as I'm still quite new to ZF2, there's a lot to learn).
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: