Java 禁用POST方法的spring安全性
我有如下的spring安全配置Java 禁用POST方法的spring安全性,java,spring,spring-security,Java,Spring,Spring Security,我有如下的spring安全配置 http.authorizeRequests().antMatchers("/css/**").permitAll().and().authorizeRequests().antMatchers("/imgs/**").permitAll().anyRequest() .fullyAuthenticated().and() //.csrf().disable().authorizeRequests().antMatchers(HttpMethod.
http.authorizeRequests().antMatchers("/css/**").permitAll().and().authorizeRequests().antMatchers("/imgs/**").permitAll().anyRequest()
.fullyAuthenticated().and()
//.csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/updatepass/**").permitAll().anyRequest().fullyAuthenticated().and()
.formLogin().loginPage("/login")
.failureUrl("/login?error=401").permitAll().and()
//.csrf().ignoringAntMatchers("/updatepass").and()
.logout().permitAll().and().csrf().disable()
.authorizeRequests().antMatchers("/register").hasRole("ADMIN").and()
.authorizeRequests().antMatchers("/registeruser").hasRole("ADMIN");
我想允许对任何请求使用/updatepass
POST方法,即使它不是经过身份验证的请求。我尝试了下面的注释配置,但它仍然抛出我的登录页面
我要打开的目标POST URL是一个API,它将接收JSON请求。完整的URL是
/updatepass
我尝试添加/**
但没有任何效果。请不要建议XML配置。请仅使用Java配置。尝试使用以下实现添加configure(WebSecurity web)
的重载方法
public void configure(WebSecurity web)
throws Exception {
web.ignoring().antMatchers(HttpMethod.POST, "/updatepass/**");
}
您可以这样使用:谢谢@fadysad,但我不想使用xml。完成Java配置。