简体   繁体   English

登录验证 - Spring 启动安全,JDBC

[英]Login authentication - Spring Boot Security, JDBC

I'm looking for an easiest way to create Login form authentication, using spring boot and JDBC.我正在寻找一种最简单的方法来创建登录表单身份验证,使用 spring 引导和 JDBC。 I've created such code so far.到目前为止,我已经创建了这样的代码。

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);
    }
}

Now I need to get user's data from Oracle database and make login form.现在我需要从 Oracle 数据库中获取用户数据并制作登录表单。 Does anyone can give me some tips?有人可以给我一些提示吗? I've seen many projects on the internet, but it's really hard to copy them.我在互联网上看过很多项目,但复制它们真的很难。

This is my first answer.这是我的第一个答案。 I just registered on stackoverflow.我刚刚在stackoverflow上注册。 It's just a test to understand stackoverflow.这只是一个了解stackoverflow的测试。 Sorry对不起

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM