Hi,
I'm trying to use org.springframework.social.security classes before they are released, so please help me if you can. My question is how to use SocialAuthenticationFilter.
In Spring Social QuickStart example, there is ProviderSignInController to handle OAuth dance. If I use SocialAuthenticationFilter, do I still need it or not?
Here is the security.xml:
The JavaConfig with related configuration beans:Code:<http use-expressions="true" entry-point-ref="socialAuthenticationEntryPoint"> <custom-filter position="PRE_AUTH_FILTER" ref="socialAuthenticationFilter" /> <logout logout-url="/signout" delete-cookies="JSESSIONID" /> <intercept-url pattern="/resources/**" access="permitAll" /> <intercept-url pattern="/signin" access="permitAll" /> <intercept-url pattern="/signin/*" access="permitAll" /> <intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" /> <intercept-url pattern="/**" access="permitAll" /> </http> <authentication-manager alias="authenticationManager"> <authentication-provider ref="socialAuthenticationProvider" /> </authentication-manager>
Not sure this is the correct way to use it.Code:@Bean public SocialAuthenticationServiceLocator socialAuthenticationServiceLocator() { SocialAuthenticationServiceRegistry registry = new SocialAuthenticationServiceRegistry(); OAuth2ConnectionFactory<Google> googleConnectionFactory = new GoogleConnectionFactory(environment.getProperty("google.clientId"), environment.getProperty("google.clientSecret")); OAuth2AuthenticationService<Google> googleAuthenticationService = new OAuth2AuthenticationService<Google>(googleConnectionFactory); googleAuthenticationService.setScope("https://www.googleapis.com/auth/userinfo.profile"); registry.addAuthenticationService(googleAuthenticationService); return registry; } @Inject private AuthenticationManager authenticationManager; @Bean public SocialAuthenticationFilter socialAuthenticationFilter() { SocialAuthenticationFilter filter = new SocialAuthenticationFilter(authenticationManager, accountService(), usersConnectionRepository(), socialAuthenticationServiceLocator()); filter.setFilterProcessesUrl("/signin"); return filter; } @Bean public SocialAuthenticationProvider socialAuthenticationProvider(){ return new SocialAuthenticationProvider(usersConnectionRepository(), accountService()); } @Bean public LoginUrlAuthenticationEntryPoint socialAuthenticationEntryPoint(){ return new LoginUrlAuthenticationEntryPoint("/signin"); }
So far I can sign in with google, but still struggle with SocialAuthenticationToken.
Thanks.


Reply With Quote
