3

春のセキュリティログインを使用しています。今、春のソーシャルFacebookログインを追加しようとしていますが、多くのエラー情報が表示されます。

まず、春のソーシャルガイドのような同じ方法を使用しようとすると、できません@Autowired private Facebook facebook

解決策を見つけました

@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook(ConnectionRepository repository) {
    Connection<Facebook> connection = repository
            .findPrimaryConnection(Facebook.class);
    return connection != null ? connection.getApi() : null;
}

次に、「Bean が見つかりません」というエラーが表示されます。追加する必要があります:

 @Bean
 public ConnectionRepository connectionRepository() {
 Authentication authentication = SecurityContextHolder.getContext()
 .getAuthentication();
 if (authentication == null) {
 throw new IllegalStateException(
 "Unable to get a ConnectionRepository: no user signed in");
 }
 return usersConnectionRepository().createConnectionRepository(
 authentication.getName());
 }

@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
    ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();

     registry.addConnectionFactory(new FacebookConnectionFactory(facebookid,
                facebookSecure));

    return registry;
}

@Bean
public AuthenticationNameUserIdSource authenticationNameUserIdSource(){
    return new  AuthenticationNameUserIdSource();
}


@Bean
public ConnectController connectController(
        ConnectionFactoryLocator connectionFactoryLocator,
        ConnectionRepository connectionRepository) {
    return new ConnectController(connectionFactoryLocator,
            connectionRepository);
}

@Bean
public UsersConnectionRepository usersConnectionRepository() {
    return new JdbcUsersConnectionRepository(dataSource,
            connectionFactoryLocator(), Encryptors.noOpText());
}

その後、私は別の問題を抱えていますjava.lang.NoSuchMethodError: org.springframework.social.security.SocialAuthenticationFilter.getFilterProcessesUrl()Ljava/lang/String;

@Bean
  public SocialAuthenticationServiceLocator socialAuthenticationServiceLocator() {
    SocialAuthenticationServiceRegistry registry = new SocialAuthenticationServiceRegistry();
    registry.addConnectionFactory(new FacebookConnectionFactory(facebookid,
            facebookSecure));
    return registry;
}

     @Bean
 public SocialAuthenticationFilter socialAuthenticationFilter()
 throws Exception {
 SocialAuthenticationFilter filter = new SocialAuthenticationFilter(
 authenticationManager(), authenticationNameUserIdSource(),
 usersConnectionRepository(), socialAuthenticationServiceLocator());
 filter.setFilterProcessesUrl("/login");
 filter.setSignupUrl("/signup");
 filter.setConnectionAddedRedirectUrl("/home");
 filter.setPostLoginUrl("/home"); // always open account profile
 // page after login
 // filter.setRememberMeServices(rememberMeServices());
 return filter;
 }

しかし、常に同じです。

これは私のhttp構成です

        http.csrf()
            .disable()
            .authorizeRequests()
            .antMatchers("/home", "/css/**", "/**/*.css*", "/", "/signup",
                    "/facebook", "/signup.xhtml").permitAll().anyRequest()
               .authenticated().and().formLogin().loginPage("/login").loginProcessingUrl("/login/authenticate")
            .defaultSuccessUrl("/home").failureUrl("/login")

            .permitAll().and().logout().logoutUrl("/logout")
            .invalidateHttpSession(true).logoutSuccessUrl("/").and()
            .apply(new SpringSocialConfigurer());

そしてコントローラー

@RequestMapping(value = "/login", method = RequestMethod.GET)
 public String loginPage() {
 return "redirect:/login/authenticate/connect/facebook";

 }

チュートリアル全体を行いました。SocialConfigurer次に、実装を削除して、同じ (@Overrideのみではなく@Bean)ソーシャル ドキュメントを作成しました。

「通常ログイン」(Spring Security) は正常に動作しますが、Spring Social を Spring Security で構成できません。JSFとファイルを使用してい.XHTMLます。

多分誰かが私がどこで間違いを犯したか知っていますか?

ご協力いただきありがとうございます。

4

4 に答える 4

1

Spring Security は、Spring Security 4.0.0.RC1 で getFilterProcessesUrl() を削除したようです (とにかく非推奨としてマークされていました)。

他のプロジェクト フィルターが更新されていないようです。

4.0.0.M2 にロールバックするか、3.2 トレインを使用してください。

于 2015-01-30T06:29:06.340 に答える
0

バージョン 1.1.4 の使用を検討してください。

これは、spring-social-security 1.1.4.RELEASE (またはそれ以前のバージョン) で解決されています。

https://github.com/spring-projects/spring-social

于 2015-11-25T02:40:35.810 に答える