小编dar*_*ose的帖子

在 Springboot 安全应用程序中公开不安全的 Restful 端点

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

spring-security spring-boot

4
推荐指数
1
解决办法
6215
查看次数

标签 统计

spring-boot ×1

spring-security ×1