2016-04-13 4 views
1

この設定は、訪問site.comた後、私はメインページを参照してくださいが、ページ春のセキュリティ、セキュアでないルートパス私のopitionで

@Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.csrf() 
       .disable() 
       .authorizeRequests() 
       .antMatchers("/resources/**").permitAll() 
       .antMatchers("/register").permitAll() 
       .antMatchers("/login").permitAll() 

       .and(); 

     http.formLogin() 
       .loginPage("/login") 
       .loginProcessingUrl("/j_spring_security_check") 
       .successHandler(getAuthenticationSuccess()) 
       .failureUrl("/login?error=accessDenied") 
       .usernameParameter("j_username") 
       .passwordParameter("j_password") 
       .permitAll() 
       .and() 
       .authorizeRequests() 
       .antMatchers("/**").authenticated() 
       .anyRequest().authenticated() 
       .and(); 
     http.logout() 
       .logoutSuccessUrl("/") 
       .logoutUrl("/logout") 
       .permitAll(); 

     http.headers().xssProtection(); 
ログインにリダイレクトされなければならないルート

からサイトのすべてのページにセキュリティを可能にしなければなりません

答えて

2

あなたは正しいです)あなたはログインページにリダイレクトしたい場合は成功URL

http.formLogin() 
       .loginPage("/login") 
       .loginProcessingUrl("/j_spring_security_check") 
       .successHandler(getAuthenticationSuccess()) 
       .failureUrl("/login?error=accessDenied") 
       .usernameParameter("j_username") 
       .passwordParameter("j_password") 
       .permitAll() 
       .and() 
       .authorizeRequests() 
       .antMatchers("/**").authenticated() 
       .anyRequest().authenticated() 
       .and() 
       .logout() 
       .logoutSuccessUrl("/login") 
       .permitAll(); 
+0

Thxをログアウトして、ログインURLを入力して、メインページを参照してください後にログアウトしなければなりません! –

関連する問題