FriendsOfSymfony / FOSOAuthServerBundle

A server side OAuth2 Bundle for Symfony
1.09k stars 451 forks source link

Events on token grant #390

Open GabrielCW opened 8 years ago

GabrielCW commented 8 years ago

I'm currently trying to hook into the token grant logic (so as to be able to refuse a specific user to obtain a token for a given client, even if this client has been authorized).

I couldn't find any guidelines about doing this, and overriding the TokenController seems to be fairly difficult to do without repeating almost all the code from OAuth2\OAuth2.

How is one supposed to go about this? The Authorize events are too restrictive for my use case.

Spomky commented 8 years ago

You could try to listen to the kernel response event and chase if an access token is returned.

krozner commented 8 years ago

I've just made a pull request #391 with handler for after token grand I'm waiting for merge or some feedback

GabrielCW commented 8 years ago

@KonradRozner 's PR should allow for the behavior I was looking for. Thanks!

Tersoal commented 8 years ago

Hi all.

Until PR been updated, I'm subscribing to postPersist event of AccessToken entity to update lastLogin field of Fos User bundle.

Cheers