I've got REST service that will be used for authentication. The authentication endpoint will look like /api/v.1/authentication
. The API version is a variable that can be changed to reflect updated versions. One example would be /api/v.2/authentication
. I like to have an antMatcher
that can deal with both these cases so I tried .antMatchers(HttpMethod.POST,"**/authenticate").permitAll()
using **
to match any beginning of the endpoint but this doesn't work. The full setup below.
@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();
}
Any suggestions how I can solve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…