Spring Boot与Spring Security整合后post请求出现403拒绝访问问题

197 阅读1分钟

记录一次Spring Boot与Spring Security整合后post请求出现403拒绝访问问题


```
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

   @Override
   protected void configure(HttpSecurity http) throws Exception {
//    super.configure(http);
      http.csrf().disable();

      http.authorizeRequests()
//          .antMatchers("/**").permitAll()
            .antMatchers("/rest/**").permitAll()
            .antMatchers("/master/**").hasRole("AUTHORIZATION");

   }

   @Override
   protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      super.configure(auth);
   }
}
```
```
```

解决方法如上: configure 中加入 http.csrf().disable(); 关闭 csrf攻击防范
[原文链接](https://blog.csdn.net/sinat_28454173/article/details/52251004)