how I can configure spring-boot-starter-security, to my own needs?
(I'm using spring with kotlin)
I mean, I have this configuration file, but it seems that spring container just ignore.
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import java.lang.Exception
@Configuration
@EnableWebSecurity
class WebSecurity : WebSecurityConfigurerAdapter() {
@Bean
public fun encriptator () : BCryptPasswordEncoder{
return BCryptPasswordEncoder();
}
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http .authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
}
is always redirect me to /login.
And the file location is at the same level of the app.kt
I got the solution, my problem was the package keyword was missing, so I move the config file to a package called config, and now its works