New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultAuthenticationListenerFactory creates own instance of OAuth2Server #45

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

Comments

Projects
None yet
2 participants
@adamlundrigan
Contributor

adamlundrigan commented Oct 20, 2014

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

This comment has been minimized.

Show comment
Hide comment
@adamlundrigan

adamlundrigan Oct 20, 2014

Contributor

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;
    }
}
Contributor

adamlundrigan commented Oct 20, 2014

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

This comment has been minimized.

Show comment
Hide comment
@solcre

solcre Mar 19, 2015

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

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 join this conversation on GitHub. Already have an account? Sign in to comment