Spring-security配置代码

@Configuration
    public static class WebSecurityConfigurer extends WebSecurityConfigurerAdapter{
        
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .formLogin()
            .and()
                .logout()
                    .invalidateHttpSession(true)
                    .logoutUrl("/logout").logoutSuccessUrl("/")
                    .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
            .and()
                .sessionManagement()
                    .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
            .and()
                .authorizeRequests()
//                    .antMatchers("/test").permitAll()
//                    .antMatchers("/**").authenticated()
                    .anyRequest().authenticated();
        }
    }

 

posted @ 2017-03-28 16:40  kingsy.lin  阅读(289)  评论(0编辑  收藏  举报