将phpleague oauth2软件包与Symfony4集成

时间:2019-02-05 12:33:25

标签: php oauth-2.0 symfony4

我正在将https://oauth2.thephpleague.com/与新的Symfony4项目集成在一起,并完成了授权服务器的过程(生成,加密和交付访问令牌)。

最后一步是集成“资源服务器”,该资源用于验证使用的访问令牌。

设置步骤非常简单,但是实际启动令牌验证的过程在文档中更加含糊。

// Init our repositories
$accessTokenRepository = new AccessTokenRepository(); // instance of 
AccessTokenRepositoryInterface

// Path to authorization server's public key
$publicKeyPath = 'file://path/to/public.key';

// Setup the authorization server
$server = new \League\OAuth2\Server\ResourceServer(
    $accessTokenRepository,
    $publicKeyPath
);

然后要求“将中间件添加到您的堆栈中”:

new \League\OAuth2\Server\Middleware\ResourceServerMiddleware($server);

我已经阅读了Symfony4中间件的文档,但是我无法获得资源服务器来实际验证令牌。我也尝试过在控制器中手动实例化和调用类,也没有任何作用。

我假设我缺少一些愚蠢的东西,任何帮助将不胜感激。

谢谢!

0 个答案:

没有答案