spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 351 forks source link

Provide different error handling strategies for failing oauth2callback #138

Open bripkens opened 10 years ago

bripkens commented 10 years ago

In ProviderSignInController#oauth2Callback (Source) all errors are caught and treated the same, i.e. the user is redirected to the sign in page. It would be great if there was some integrated way to modify this behavior in certain cases.

In my specific case an automatic sign up may be rejected by throwing an exception in an implementation of ConnectionSignUp. I would prefer to show the users the reason for the sign up rejection instead of redirecting them to the sign in page.

A very simple solution (which I could provide via PR) would maintain the existing behavior while providing configuration options (thinking along the lines of putting the catch block in a separate method which could be overriden).

johndeverall commented 9 years ago

I'd like something similar for handling DuplicateConnectionException thrown from ConnectionRepository implementations. Currently this exception is swallowed by ConnectController and all I get to know about it is ${social_addConnection_duplicate} (value = true) as a model attribute.

jtbdevelopment commented 9 years ago

I'd like something similar for both success and failure. In spring security you are able to inject your own handlers. In spring social you cannot. I have a version of spring social configurer that allows you do so.

See https://github.com/jtbdevelopment/core-games/blob/master/games-web/src/main/groovy/com/jtbdevelopment/games/security/spring/social/MobileAwareSocialConfigurer.groovy and search for 3 places marked 'custom code begin' that allows custom handlers which has limited changes and is in same spirit of spring security

Would be happy to clean up and contribute a PR.