O código abaixo segue a versão atualizada sem implementar os métodos do WebSecurityConfigureAdapter que está defasado:
@Configuration
@EnableWebSecurity
class SecurityConfiguration (
private val userDetailsService: UsuarioService
) {
@Bean
fun filterChain(http: HttpSecurity): SecurityFilterChain {
http?.authorizeRequests()?.anyRequest()?.authenticated()?.and()?.sessionManagement()
?.sessionCreationPolicy(SessionCreationPolicy.STATELESS)?.and()?.formLogin()?.disable()
?.httpBasic(withDefaults())
?.userDetailsService(userDetailsService)
return http.build()
}
@Bean
fun encoder(): PasswordEncoder? {
return BCryptPasswordEncoder()
}
@Bean
@Throws(Exception::class)
fun authenticationManager(authConfig: AuthenticationConfiguration): AuthenticationManager? {
return authConfig.authenticationManager
}
}