Skip to content

Email or Password invalid, please verify #5

@bantibaghel

Description

@bantibaghel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions