2017-06-03 4 views
1

ここに問題が残っています。私は私のアプリケーションのためのプライムフェイスのスプリングブートを使用しています。私は春のセキュリティを認証に使用しています。どういうわけか私はアクセスが拒否されています。それに加えて、ユーザーは既にmongodbに設定されています。もし私がスプリングリダイレクトを使用していれば、すべてがうまくいきます。スプリングセキュリティスプリングブート4.x

http.csrf().csrfTokenRepository(csrfTokenRepository()).and().authorizeRequests().antMatchers("/login**").access("permitAll") 
      .antMatchers("/logout**").access("permitAll") 
      .antMatchers("/secure/homePage.xhtml").access("hasRole('ADMIN') or hasRole('USER')") 
      .anyRequest().authenticated().and().formLogin().loginPage("/login").defaultSuccessUrl("/secure/homePage.xhtml") 
      .failureUrl("/login.xhtml?error").usernameParameter("email").and().logout().logoutUrl("/logout.xhtml") 
      .logoutSuccessUrl("/login.xhtml").invalidateHttpSession(true).clearAuthentication(true).and() 
      .exceptionHandling().accessDeniedPage("/accessDenied.xhtml"); 

はところで、私は私のログインページに次のようにあります

<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> 
+0

helloWorld.xhtmlは、あなたがこの[例](https://github.com/spring-projects/spring-boot/tree/master/springを参照してくださいとしています-boot-samples/spring-boot-sample-web-method-security)プロジェクトをgithubで実行します。彼らには解決策があるかもしれません。 –

答えて

0

エンドポイントについて怪しい何かがあります。

これらは、/secure/homePage.xhtmlです。これらは通常コントローラメソッドを指しており、コントローラではビューにパスを指定します。特定のビューリゾルバがそのページを配信します。この例では

@Bean 
ViewResolver viewResolver() { 
    InternalResourceViewResolver resolver = new InternalResourceViewResolver(); 
    resolver.setViewClass(org.springframework.faces.mvc.JsfView.class); 
    resolver.setPrefix("/WEB-INF"); 
    resolver.setSuffix(".xhtml"); 
    return resolver; 

} 


@Controller 
public class HelloWorldController { 

    @RequestMapping("/helloWorld") 
    public String helloWorld(Model model) { 
     model.addAttribute("message", "Hello World!"); 
     return "helloWorld"; 
    } 
} 

、あなたは/WEB-INF/