【发布时间】:2019-11-15 06:25:03
【问题描述】:
在 Spring 框架中,我目前正在尝试使用自定义标头而不是 url 来区分某些端点。目前,我似乎看不到如何允许具有自定义标头的特定 URL,但在 Spring Security 中拒绝另一个。我的安全配置当前有一个 antMatcher,如下所示:
.antMatchers( HttpMethod.POST, "/api/website-user" ).permitAll()
但是,我还有一些其他的“POST”方法也受到保护——对于这个特定的端点,我只希望通过发送的标头来识别和排除它。
你是怎么告诉 Spring 安全这个 URL 应该未经身份验证通过的
@PostMapping( headers = "X-Operation-Name=forgot-password" )
public WebsiteUser forgotPassword( @Valid PasswordResetRequestModel passwordReset )
但是例如这个不(并且依赖于经过身份验证的用户)?
@PostMapping( headers = "X-Operation-Name=resend-verification" )
public WebsiteUser resendVerification( Principal principal )
【问题讨论】:
标签: java spring spring-boot spring-security http-headers