KnpLabs/KnpOAuthBundle — Issue #15: Re-usable Http/OAuth providers services? + Custom 'requiresAuthentication' handler?
Author: asm89
Created: 2012-01-31 15:33:23+00:00
State: open

I'm trying to integrate KnpOAuthBundle together with FOSUB to allow users to connect their social accounts (github, facebook etc) to already existing user accounts and login with those instead. Configuring the OAuth firewall works fine, but connecting the social accounts to an already logged in user seems to be a great challenge. When a user is already logged in and the user provider can't find an account linked to github, an exception is thrown and the user is logged out. In order to get this to work I would need one small addition to the `Firewall/OAuthListener` as described below.

**Would it be possible to register some custom function to determine whether authentication is required or not?**
To be able to skip oAuth authentication when a user is already logged in via a UsernamePasswordToken, the [Firewall/OAuthListener](https://github.com/KnpLabs/KnpOAuthBundle/blob/master/Security/Http/Firewall/OAuthListener.php) should skip the authentication process by not requiring it. Do you see a possibility to add a custom `requiresAuthentication`-handler that can optionally be registered to make this decision?

**Make the Http/OAuth providers available?**
If the firewall skips the authentication of a user, a controller or something else would still need to get an access token etc from the oauth server in order to show the right credentials to a user (Do you want to link the github account "asm89" to this account?). It would be nice if the current oauth code could be re-used somehow?