【发布时间】:2017-09-27 23:59:52
【问题描述】:
我有用于身份验证的 REST 服务。身份验证端点看起来像/api/v.1/authentication。 API 版本是一个可以更改以反映更新版本的变量。一个例子是/api/v.2/authentication。我喜欢有一个antMatcher 可以处理这两种情况,所以我尝试使用.antMatchers(HttpMethod.POST,"**/authenticate").permitAll() 使用** 来匹配端点的任何开头,但这不起作用。下面的完整设置。
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf().disable()
.authorizeRequests()
.antMatchers(HttpMethod.POST, "**/authenticate").permitAll()
.antMatchers(HttpMethod.GET, "**/get-public-key").permitAll()
.and()
.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.anyRequest().authenticated();
}
有什么建议可以解决这个问题吗?
【问题讨论】:
标签: spring spring-boot spring-security