knpuniversity / oauth2-client-bundle

Easily talk to an OAuth2 server for social functionality in Symfony
https://symfonycasts.com
MIT License
779 stars 146 forks source link

Problem with configuration generic client #186

Open asb1301 opened 5 years ago

asb1301 commented 5 years ago

Problem with configuration generic ouath2-client: https://github.com/ekapusta/oauth2-esia

This client requires data (signer) in collaborators array in Provider construct

public function __construct(array $options = [], array $collaborators = [])
    {
        parent::__construct($options, $collaborators);
        if (!filter_var($this->remoteUrl, FILTER_VALIDATE_URL)) {
            throw new InvalidArgumentException('Remote URL is not provided!');
        }
        if (!file_exists($this->remoteCertificatePath)) {
            throw new InvalidArgumentException('Remote certificate is not provided!');
        }

        if (isset($collaborators['signer']) && $collaborators['signer'] instanceof SignerInterface) {
            $this->signer = $collaborators['signer'];
            $this->encoder = new Encoder();
        } else {
            throw new InvalidArgumentException('Signer is not provided!');
        }
    }

But through parameters in the yaml file, I can pass only the _provideroptions array. Is it possible to pass collaborators array with signer?

weaverryan commented 5 years ago

Hi there!

I don't think this is currently possible - sorry. But, it could be easily added - we DO manage this collaborators array, we just need to add a signer to it. Probably we would need to:

1) Add a new option for each client - I think here: https://github.com/knpuniversity/oauth2-client-bundle/blob/f6743e226083c4760021ec7a1743dd1af2bfbc45/src/DependencyInjection/KnpUOAuth2ClientExtension.php#L332-L349

2) Then check for that key and use it around here: https://github.com/knpuniversity/oauth2-client-bundle/blob/f6743e226083c4760021ec7a1743dd1af2bfbc45/src/DependencyInjection/KnpUOAuth2ClientExtension.php#L199

A PR would be warmly welcomed!

Cheers!