[英]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.