Estou com dificuldades em prosseguir com a aula atual devido às alterações mais recentes do SpringSecurity:
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
Eu fiz uma modificação na minha classe e gostaria de sabe se essa é a abordagem mais correta:
package br.com.architectbudgeplanner.config
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.Customizer
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.http.SessionCreationPolicy
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.web.SecurityFilterChain
@Configuration
@EnableWebSecurity
class SecurityConfiguration {
@Bean
fun filterChain(http: HttpSecurity) : SecurityFilterChain {
return http.authorizeHttpRequests {
it.anyRequest().authenticated()
}.sessionManagement {
it.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
}.formLogin {
it.disable()
}.httpBasic(Customizer.withDefaults()).build()
}
@Bean
fun encoder(): PasswordEncoder? {
return BCryptPasswordEncoder()
}
}