0

我正在尝试使用 JWT 身份验证扩展 Symfony 应用程序。令牌将由远程服务器颁发,该服务器提供 JWKS URL 来检索公钥。

不幸的是,我似乎遇到了web-token/jwt-bundle,httpplugguzzle.

为了获得 JWT 和 JWKS 身份验证器,我安装了

包裹 版本
lexik/jwt-authentication-bundle v2.14.1
spomky-labs/lexik-jose-bridge v3.0.2
php-http/缓存插件 1.7.3
php-http/guzzle7-适配器 1.0.0
php-http/httplug-bundle 1.24.0
guzzlehttp/guzzle 7.4.0

起初,我用 guzzle v6 尝试过这个,但遇到了完全相同的问题。所以这个问题描述是针对 guzzle v7 的。

spomky-labs/lexik-jose-bridge所需:

包裹 版本
web-token/jwt-bundle v2.2.11
网络令牌/jwt-checker v2.2.11

按照我配置的说明:

httplug:
    plugins:
        cache:
            cache_pool: 'cache.app'
            config:
                default_ttl: 1800
    clients:
        acme:
            # factory: 'httplug.factory.guzzle6'
            factory: 'httplug.factory.guzzle7'
            plugins: ['httplug.plugin.cache']

jose:
    jku_factory:
        enabled: true
        client: 'httplug.client.acme'
        request_factory: 'httplug.message_factory'

一旦我尝试验证令牌,我会收到以下错误消息:

传递给的参数 2Jose\Component\KeyManagement\UrlKeySetFactory::__construct()
必须是 的实例Psr\Http\Message\RequestFactoryInterface,给定的实例,
在 第12行第 35行 调用Http\Message\MessageFactory\GuzzleMessageFactory
/app/var/cache/dev/ContainerMJf4ii2/getJKUFactoryService.php
/app/vendor/web-token/jwt-key-mgmt/UrlKeySetFactory.php

似乎UrlKeySetFactory期望一个RequestFactoryInterface但得到一个实现RequestFactory

由于 guzzle v7 已经实现了该RequestFactory接口,我对配置进行了如下调整:

services.GuzzleHttp\Psr7\HttpFactory: ~
jose.jku_factory.request_factory: 'GuzzleHttp\Psr7\HttpFactory'

这似乎有效。我只是想知道这是否是正确的做法。

4

0 回答 0