Quando pesquiso por "/v3/api-docs" no Swagger, recebo o seguinte erro: "response status is 403 /v3/api-docs".
Minha SecurityConfig está assim:
package br.com.alura.Alura.config
@Configuration @EnableWebSecurity class SecurityConfig ( private val userDetailsService: UserDetailsService, private val jwtUtil: JWTUtil ): WebSecurityConfigurerAdapter(){ override fun configure(http: HttpSecurity?) { http?. csrf()?.disable()?. authorizeRequests()?. antMatchers("/topicos")?.hasAnyAuthority("LEITURA")?. antMatchers(HttpMethod.GET, "/swagger-ui/")?.permitAll()?. antMatchers(HttpMethod.GET, "v3/api-docs/*")?.permitAll()?. antMatchers(HttpMethod.POST,"/login")?.permitAll()?. anyRequest()?. authenticated()?. and() http?.addFilterBefore(JWTLoginFilter(authManager = authenticationManager(), jwtUtil = jwtUtil), UsernamePasswordAuthenticationFilter().javaClass) http?.addFilterBefore(JWTAutheticationFilter(jwtUtil = jwtUtil), UsernamePasswordAuthenticationFilter().javaClass) http?.sessionManagement()?. sessionCreationPolicy(SessionCreationPolicy.STATELESS) //não guarda o estado da aplicação }
@Bean
fun bCryptPasswordEncoder(): BCryptPasswordEncoder{
return BCryptPasswordEncoder()
}
override fun configure(auth: AuthenticationManagerBuilder?) {
auth?.userDetailsService(userDetailsService)?.passwordEncoder(bCryptPasswordEncoder())
}
}