Here is the code in which the authorization.

@Autowired public void configureSecurity(final AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource) .usersByUsernameQuery("select user_name, user_password_hash, user_id from rs_user where user_name=?") .authoritiesByUsernameQuery("select user_name, user_is_administrator, user_id from rs_user where user_name=?"); } /** * Configure http. * @param http of HttpSecurity type * @throws Exception of authentication exception */ @Override public void configure(final HttpSecurity http) throws Exception { http.formLogin().and().authorizeRequests().anyRequest().authenticated() .and().formLogin().successHandler(savedRequest()) .usernameParameter("login") .passwordParameter("password") .and().csrf().disable().rememberMe().tokenRepository(persistenceTokenReposetory()) .tokenValiditySeconds(400000000); } 

What causes this error? Is there a problem in csrf, or did I form a wrong query? Login and password pull from PostgreSQL database

    1 answer 1

    According to the documentation , the user has an enabled property. However, in your sql'nikiki there is no sample of it, therefore by default it is equal to false . You need to add a sample of this property in sql'nik. If you want it to always be true , then you need to add true as enabled . The result will be approximately

     .authoritiesByUsernameQuery("select user_name, user_is_administrator, user_id, true as enabled from rs_user where user_name=?");