I was using an older version of springboot where the spring security was using WebSecurityConfigAdapter and the below mentioned code was working fine.
override fun configure(http: HttpSecurity) {
http
.httpBasic()
.and()
.csrf().disable()
.authorizeRequests()
.mvcMatchers("/version").permitAll()
.antMatchers("/api/v1/{personId}/**").permitAll()
}
I moved to Spring Security 6 and spring boot 3.2 and WebSecurityConfigAdapter is deprecated.
Handled it as :
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
http.httpBasic(Customizer.withDefaults())
.csrf { csrf -> csrf.disable() }
.authorizeHttpRequests { auth ->
auth.requestMatchers("/version").permitAll()
auth.requestMatchers("/swagger-v3/api-docs").permitAll()
}
}
Initially I had a testcase where my version endpoint was working fine with both “/version” and “/version/”.
But now for “/version/” I am getting a 401. Similarly getting 401 for /swagger-v3/api-docs
as well.
Could someone help in understanding what changed or how can I fix it ?