hellokoding / registration-login-spring-hsql

Registration and Login Example with Spring Security, Spring Boot, Spring Data JPA, HSQL, JSP
https://hellokoding.com/registration-and-login-example-with-spring-security-spring-boot-spring-data-jpa-hsql-jsp/
MIT License
224 stars 259 forks source link

Email or Password invalid, please verify #5

Open bantibaghel opened 6 years ago

bantibaghel commented 6 years ago

Hi, I am facing authentication issue at login time. I am using jdbcauthentication. Email and password are available in db and both users-query and roles-query are working perfectly but email and password does not get match or I think not get from login page. I do not know how it is authenticate. Please help me as soon as possible.

Thanks, Banti kumar

@Value("${spring.queries.users-query}") private String usersQuery;

@Value("${spring.queries.roles-query}")
private String rolesQuery;

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    // TODO Auto-generated method stub
    auth.jdbcAuthentication()
        .usersByUsernameQuery(usersQuery)
        .authoritiesByUsernameQuery(rolesQuery)
        .dataSource(dataSource)
        .passwordEncoder(bCryptPasswordEncoder);    
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests()
                  .antMatchers("/").permitAll()
                  .antMatchers("/login").permitAll()
                  .antMatchers("/registration").permitAll()
                  .antMatchers("/admin/**").hasAnyAuthority("ADMIN").anyRequest()
                  .authenticated().and().csrf().disable().formLogin()
                  .loginPage("/login").failureUrl("/login?error=true")
                  .defaultSuccessUrl("/admin/home")
                  .usernameParameter("email")
                  .passwordParameter("password")
                  .and().logout()
                  .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                  .logoutUrl("/").and().exceptionHandling()
                  .accessDeniedPage("/beacon/user/access-denied");          

}

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring()
       .antMatchers("/resources/**","/static/**","/css/**","/js/**","/images/**");
}
reborne commented 6 years ago

Greetings! You've mentioned: "I am using jdbcauthentication. Email and password are available in db and both users-query and roles-query are working perfectly"

In what type does password stores in your database (plain-style password(e.g "abcdefg") or encrypted?)

bantibaghel commented 6 years ago

Thanks for your precious response. My problem has been resolved.

Regards, Banti Kumar

On Nov 30, 2017 19:53, "Artyom Ulanchik" notifications@github.com wrote:

Greetings! You've mentioned: "I am using jdbcauthentication. Email and password are available in db and both users-query and roles-query are working perfectly"

In what type does password stores in your database (plain-style password(e.g "abcdefg") or encrypted?)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hellokoding/registration-login-spring-hsql/issues/5#issuecomment-348201893, or mute the thread https://github.com/notifications/unsubscribe-auth/AO9SEfEPFBhQaRFsKNMhjSYT6KhdP17xks5s7rpPgaJpZM4QkMm8 .

Rajborwade12 commented 6 years ago

how to mute the thread i have also same problem