0

嗨,

我想在我的表达应用程序中使用这个模块( https://github.com/phly/phly-expressive-oauth2clientauthentication )。

我读了这个文档https://phly.github.io/phly-expressive-oauth2clientauthentication

这是我所做的:

在我的 config/autoload 文件夹中,我用这个数组添加了一个 oauth2clientauthentication.global.php :

'oauth2clientauthentication' => [
    'routes' => [
        'production' => '/(:provider)(/oauth2callback)',
    ],
],

在我的 pipeline.php 文件中我添加

use Phly\Expressive\OAuth2ClientAuthentication\OAuth2CallbackMiddleware;

$app->pipe('/auth', OAuth2CallbackMiddleware::class);

在我的 ConfigProvider.php 文件中,我使用此配置添加了一条路由(我使用带有https://github.com/acelaya/expressive-slim-router的超薄路由器:

[
    'name' => 'admin',
    'path' => '/admin',
    'allowed_methods' => ['GET'],
    'middleware' => [
        SessionMiddleware::class,
        AuthenticationMiddleware::class,
        Action\AdminAction::class,
    ],

当我尝试这个网址时:' http://blog/admin ',我得到了带有 github 按钮的未经身份验证的页面。但是当我点击按钮时,网址是:' http://blog/auth/github?redirect=http://blog/admin '并得到一个错误:

Unable to resolve service "Zend\Expressive\Delegate\NotFoundDelegate"

我不明白问题出在哪里,有人有解决这个问题的想法吗?

4

1 回答 1

1

看起来您升级了您的 Expressive 安装,而没有通过迁移指南

检查您的config/autoload/dependencies.global.php. 它应该包含如下内容:

use Zend\Expressive\Container\NotFoundDelegateFactory;
use Zend\Expressive\Delegate\NotFoundDelegate;

return [
    'dependencies' => [
        'aliases' => [
            'Zend\Expressive\Delegate\DefaultDelegate' => NotFoundDelegate::class,
        ],

        'factories' => [
            NotFoundDelegate::class => NotFoundDelegateFactory::class,
        ],
    ],
];
于 2018-02-04T07:03:28.473 回答