gigablah / silex-oauth

Silex provider for lusitanian/oauth.
MIT License
109 stars 24 forks source link

Allow passing of additional authorization uri parameters #29

Open oniric85 opened 8 years ago

oniric85 commented 8 years ago

I see that authorization uri is built here https://github.com/gigablah/silex-oauth/blob/master/src/Security/Firewall/OAuthAuthenticationListener.php#L135

The method getAuthorizationUri accepts an array of parameters so it would be cool if we could use that to pass additional information during the uri build process. I'm asking this because I would like to dinamically configure an authorization url parameter and, untill now, I've failed to find an alternative solution.

gigablah commented 8 years ago

I could have the dispatcher fire an event with the authorization params array, so you could modify it with an event listener. Would that solve your issue?

if (null !== $this->dispatcher) {
    $authEvent = new FilterAuthEvent($authorizationParameters);
    $this->dispatcher->dispatch(OAuthEvents::AUTH, $authEvent);
    $authorizationParameters = $authEvent->getAuthorizationParameters();
}
oniric85 commented 8 years ago

Thanks for your reply, I thought about such an approach. It seems quite reasonable, only other option I thought about is to allow passing query string parameters to service login_url which are then passed to the authorization url before the redirect. Not sure if this is as clean as the dispatcher approach.