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

DefaultAuthenticationListenerFactory creates own instance of OAuth2Server #45

Closed
adamlundrigan opened this issue Oct 20, 2014 · 2 comments

Comments

@adamlundrigan
Copy link
Contributor

I'm attempting to integrate Satellizer with Apigility. Satellizer uses JWT Bearer, which requires some extra setup on the Apigility side (in bshaffer/oauth2-server-php, technically). zf-mvc-auth's DefaultAuthenticationListenerFactory pulls all the pieces from zf-oauth2's configuration and builds a new OAuth2Server instance rather than pulling the pre-configured one that zf-oauth2 slaved long and hard to construct. Would it be acceptable to modify the factory to pull the preconfigured instance? (If yes, I can provide a PR)

Source: https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Factory/DefaultAuthenticationListenerFactory.php#L75

@adamlundrigan
Copy link
Contributor Author

Simplest workaround for this in the meantime is to add a delegator to the SM which injects the proper OAuth2Server instance:

<?php
namespace LdcSategility\Factory;

use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZF\MvcAuth\Authentication\DefaultAuthenticationListener;

class HackedAuthenticationListenerFactory implements DelegatorFactoryInterface
{
    public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
    {
        $listener = call_user_func($callback);
        if ( ! $listener instanceof DefaultAuthenticationListener ) {
            return $listener;
        }

        $listener->setOauth2Server(
            $serviceLocator->get('ZF\OAuth2\Service\OAuth2Server')
        );

        return $listener;
    }
}

adamlundrigan added a commit to adamlundrigan/zf-mvc-auth that referenced this issue Oct 24, 2014
@solcre
Copy link

solcre commented Mar 19, 2015

Any updates on this ? We are planning to integrate Satellizer with Apigility as well

weierophinney added a commit that referenced this issue Mar 26, 2015
weierophinney added a commit that referenced this issue Mar 26, 2015
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