dar*_*ose 4 spring-security spring-boot
我想在 Springboot 安全应用程序中公开不安全的 Restful 端点。对端点 /api/notify 的 GET 请求有效,但 POST 请求会导致 403。如何配置以便远程客户端可以从该服务器 POST 到 /api/notify?
我的扩展 WebSecurityConfigurerAdapter 如下所示:
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/signup").permitAll()
.antMatchers("/reset").permitAll()
.antMatchers("/api/notify").permitAll()
.anyRequest().authenticated();
http
.formLogin()
.defaultSuccessUrl("/home")
.failureUrl("/login?error")
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
Run Code Online (Sandbox Code Playgroud)
我想这就是您正在寻找的:
@Configuration
@EnableWebMvcSecurity
public class SecurityCtxConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers(HttpMethod.POST,
"<YOUR URL>");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6215 次 |
| 最近记录: |