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 spring boot error #8

Open Rajborwade12 opened 6 years ago

Rajborwade12 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.

@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/**"); }