thephpleague / oauth2-server-bundle

Symfony bundle for the OAuth2 Server.
MIT License
181 stars 88 forks source link

Allow modifying scopes in AuthorizationRequestResolveEvent #155

Open Amunak opened 1 year ago

Amunak commented 1 year ago

Sometimes there's a need to allow the user to select optional scopes to allow or exclude from any given AuthorizationRequest.

We already have a good event to hook into to let the user decide whether they want to permit an OAuth connection or not, but there is no option in this (or later) event to modify the scopes.

This PR attempts to address that.

chalasr commented 1 year ago

Looks sensible to me, thanks for the PR. Could you add some test?

Amunak commented 1 year ago

Could you add some test?

I'm not really sure how or what to test - it appeared to me that events aren't tested at all, so there's no good place to add this without also testing the events.

Obviously I could add a unit test for the setter but that doesn't really help much. For what it's worth I actually tested this solution and it worked so unless I botched copying it it should be fine.