[英]Login authentication - Spring Boot Security, JDBC
我正在尋找一種最簡單的方法來創建登錄表單身份驗證,使用 spring 引導和 JDBC。 到目前為止,我已經創建了這樣的代碼。
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/index").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/")
.defaultSuccessUrl("/new", true)
.permitAll()
.and()
.logout()
.permitAll();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/css/**");
web.ignoring().antMatchers("/images/**");
}
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user =
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new InMemoryUserDetailsManager(user);
}
}
現在我需要從 Oracle 數據庫中獲取用戶數據並制作登錄表單。 有人可以給我一些提示嗎? 我在互聯網上看過很多項目,但復制它們真的很難。
這是我的第一個答案。 我剛剛在stackoverflow上注冊。 這只是一個了解stackoverflow的測試。 對不起
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.