web-token / jwt-framework

JWT Framework
MIT License
884 stars 106 forks source link

Do not deprecate the support for PSR-18 HTTP clients #534

Open Cyperghost opened 6 months ago

Cyperghost commented 6 months ago

Description

https://github.com/web-token/jwt-framework/blob/1dbef13afb91a576d5ce431e5f9570183b19c0dd/src/Library/KeyManagement/UrlKeySetFactory.php#L22-L31

In our application we use Guzzle and not any feature of Symfony. Is there any point that you can support PSR-18 HTTP clients too?

It would be good to have the same solutions as https://github.com/web-auth/webauthn-framework/issues/482 Another solution would be to move UrlKeySetFactory to the bundle.

Example

No response

Spomky commented 6 months ago

Hi,

Actually, the JKUFactory and the X5UFactory can be easily extended to be used with any HTTP Client. In version 4.0, symfony/http-client will be mandatory only if you use the classes, but you are free to implement your own class.


namespace Acme;

use GuzzleHttp\Client;
use Jose\Component\KeyManagement\JKUFactory;

final class GuzzleJKUFactory extends JKUFactory
 {
    pulbic function __construct(private readonly Client $client) {}

    /**
     * @param array<string, string|string[]> $header
     */
    protected function getContent(string $url, array $header = []): string
    {
        //Place Guzzle calls here
        $this->client->request(...
    }
}