Skip to content
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

PSR-15 version #942

Open
diogodomanski opened this issue Sep 16, 2018 · 2 comments
Open

PSR-15 version #942

diogodomanski opened this issue Sep 16, 2018 · 2 comments

Comments

@diogodomanski
Copy link

Hi,

I'm currently using the PSR-7 version with Zend Expressive 2, but I'm facing some obstacles on adapting it to work with Zend Expressive 3.

Is there any plans to create a PSR-15 version of this project?

Is there any guideline to make it work with Zend Expressive 3?

Thanks

@Sephster
Copy link
Member

Hi @diogodomanski. The library doesn't support PSR-15 at the moment but we will add support for this as our middleware was created prior to this standard. There isn't any guidance on how to achieve this as yet.

We will likely release this in version 8 of the package which is currently some way off being released.

@xgin
Copy link

xgin commented Jan 6, 2019

I use the following factory for AuthorizationServerMiddleware with Zend Expressive 3:

use Psr\Container\ContainerInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use League\OAuth2\Server\Middleware\AuthorizationServerMiddleware;
use League\OAuth2\Server\AuthorizationServer;

class AuthorizationServerMiddlewareFactory
{
   public function __invoke(ContainerInterface $container) {
        $middleware = new AuthorizationServerMiddleware($container->get(AuthorizationServer::class));

        return new class ($middleware) implements MiddlewareInterface {
            private $middleware;

            public function __construct(callable $middleware)
            {
                $this->middleware = $middleware;
            }

            public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
            {
                return ($this->middleware)(
                    $request,
                    new \Zend\Diactoros\Response(),
                    function ($request, $response) {
                        return $response;
                    }
                );
            }
        };
    }
}

For ResourceServerMiddleware is enough to wrap it with Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants