FriendsOfSymfony / FOSOAuthServerBundle

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

Unhandled OAuth2AuthenticateException #395

Open elgrafico opened 8 years ago

elgrafico commented 8 years ago

Getting the auth token from request might throw an exception which is not handled and thus leading to a HTTP status 500 whereas a 400 would be appropiate.

https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Security/Firewall/OAuthListener.php#L67

Execption is thrown e.g. here: https://github.com/FriendsOfSymfony/oauth2-php/blob/master/lib/OAuth2.php#L544

david-vde commented 8 years ago

Hello

Same issue here.

My Event listener, is not called for these exception.

This is a real issue because I'm showing custom jsons with several additional fields, and I'm unable to add it in that case.

Is there a solution to that?

My defined exception listener in the yml:

app.exception_listener:
    class: ***\Utils\EventListener\ExceptionListener
    arguments: ["@service_container"]
    tags:
        - { name: kernel.event_listener, event: kernel.exception }
    calls:
        -   [ setContainer,["@service_container"] ]