So some code.
Here is the section in our index.jsp page for connect/login to FaceBook and Twitter.
We have a single page app, so on the home main page is a login username/password in the Bootstrap nav, and a Registration form under that in the content/body section and these two buttons underneath the registration form
Code:
<section class="row-fluid">
<section class="span3 offset9">
<div class="divider">Or</div>
<!-- TWITTER CONNECT -->
<form id="tw_register" action="/connect/twitter" method="POST">
<button type="submit" class="btn btn-block btn-danger">
<img class="icon-align-left icon-resize-horizontal" src="/resources/images/twitter/t_logo-a.png"/>
Register with Twitter
</button>
</form>
<!-- FACEBOOK CONNECT -->
<form name="fb_register" id="fb_register" action="/connect/facebook" method="POST">
<input type="hidden" name="scope" value="publish_stream,user_photos,offline_access" />
<button type="submit" class="btn btn-block btn-danger">
<img class="icon-align-left icon-resize-horizontal" src="resources/images/social/facebook_32.png"/>
Register with Facebook
</button>
</form>
</section>
</section>
here is the configuration
Code:
@Configuration
@EnableJdbcConnectionRepository
@EnableTwitter(appId="${twitter.consumerKey}", appSecret = "${twitter.consumerSecret}")
@EnableFacebook(appId = "${facebook.clientId}", appSecret = "${facebook.clientSecret}")
public class SocialConfig {
@Autowired
SpringSecuritySignInAdapter springSecuritySignInAdapter;
@Autowired
ConnectionFactoryLocator connectionFactoryLocator;
@Autowired
ConnectionRepository connectionRepository;
@Autowired
UsersConnectionRepository usersConnectionRepository;
@Bean
public ConnectController connectController() {
ConnectController connectController = new ConnectController(connectionFactoryLocator, connectionRepository);
connectController.setApplicationUrl("${site.url}");
return connectController;
}
@Bean
public ProviderSignInController providerSignInController(RequestCache requestCache) {
return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SpringSecuritySignInAdapter(requestCache) );
}
@Bean
public UserIdSource userIdSource() {
SpringSecurityAuthenticationNameUserIdSource userIdSource = new SpringSecurityAuthenticationNameUserIdSource();
return userIdSource;
}
}
Here is the Encryptor
Code:
<bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors"
factory-method="text">
<constructor-arg value="${security.encryptPassword}" />
<constructor-arg value="${security.encryptSalt}" />
</bean>
Our dispatcherServlet is mapped to "/"
I believe that is all the code/configuration currently in our application. I do have a custom UserDetailsService and a custom UserDetails for Spring Security, but there is no Spring Social code in it. Also there are no Controllers with @RequestMapping to any social URL, which I might end up needing.
Thanks
Mark