gpt4 book ai didi

spring-security - 在 Springboot Secured 应用程序中暴露不安全的 Restful 端点

转载 作者:行者123 更新时间:2023-12-04 07:19:19 25 4
gpt4 key购买 nike

我想在 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();
}

最佳答案

我认为这就是你要找的:

@Configuration
@EnableWebMvcSecurity
public class SecurityCtxConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers(HttpMethod.POST,
"<YOUR URL>");
}

关于spring-security - 在 Springboot Secured 应用程序中暴露不安全的 Restful 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25879056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com