title: Spring Security Login Captcha integration
body: <p>I have integrated a Captcha plugin on Spring MVC Security. The problem is that even if i have a bad captcha but good credentials it will login but show me bad captcha.</p>
  
  <p>I think my problem is in the spring-security file:</p>
  
  <pre><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/security"
      xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.2.xsd"&gt;
  
      &lt;!-- enable use-expressions --&gt;
  
      &lt;http auto-config="true" use-expressions="true"&gt;
          &lt;intercept-url pattern="/admin**/**" access="hasRole('ROLE_ADMIN')" /&gt;
          &lt;intercept-url pattern="/jtabuleiros/play/*" access="authenticated" /&gt;
          &lt;intercept-url pattern="/details" access="hasRole('ROLE_CONCORRENTE')" /&gt;
  
  
          &lt;custom-filter ref="captchaCaptureFilter" before="FORM_LOGIN_FILTER"/&gt;
          &lt;custom-filter ref="captchaVerifierFilter" after="FORM_LOGIN_FILTER"/&gt;
  
  
          &lt;!-- access denied page --&gt;
          &lt;access-denied-handler error-page="/403" /&gt;
          &lt;form-login 
              login-page="/login" 
              default-target-url="/welcome"
              authentication-failure-url="/login?error" 
              username-parameter="username"
              password-parameter="password" /&gt;
          &lt;logout logout-success-url="/login?logout" /&gt;
          &lt;!-- enable csrf protection --&gt;
          &lt;csrf /&gt;
      &lt;/http&gt;
  
  
  &lt;!--    &lt;authentication-manager&gt; --&gt;
  &lt;!--        &lt;authentication-provider user-service-ref="myUserDetailsService" &gt; --&gt;
  &lt;!--            &lt;password-encoder hash="bcrypt" /&gt;     --&gt;
  &lt;!--        &lt;/authentication-provider&gt; --&gt;
  &lt;!--    &lt;/authentication-manager&gt; --&gt;
  
  
      &lt;beans:bean id="customUserDetailsService"
          class="com.setelog.spring.service.CustomUserDetailsService"&gt;
          &lt;beans:property name="usersByUsernameQuery" value="select * from users where username = ?"/&gt;
          &lt;beans:property name="authoritiesByUsernameQuery" value="select username, role from user_roles where username =?" /&gt;
          &lt;beans:property name="dataSource" ref="dataSource" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="userDetailsDao" class="com.setelog.spring.dao.UserDetailsDaoImpl" &gt;
          &lt;beans:property name="dataSource" ref="dataSource" /&gt;
      &lt;/beans:bean&gt;
  
      &lt;beans:bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/&gt;
  
  
      &lt;beans:bean id="authenticationProvider"
          class="com.setelog.spring.handler.LimitLoginAuthenticationProvider"&gt;
          &lt;beans:property name="userDetailsService" ref="customUserDetailsService" /&gt;
          &lt;beans:property name="userDetailsDao" ref="userDetailsDao" /&gt;
          &lt;beans:property name="passwordEncoder" ref="encoder" /&gt;
  
      &lt;/beans:bean&gt;
  
      &lt;!-- For capturing CAPTCHA fields --&gt;
   &lt;beans:bean id="captchaCaptureFilter" class="com.setelog.spring.businessrules.CaptchaCaptureFilter" /&gt;
  
   &lt;!-- For verifying CAPTCHA fields --&gt;
   &lt;!-- Private key is assigned by the reCATPCHA service --&gt;
   &lt;beans:bean id="captchaVerifierFilter" class="com.setelog.spring.businessrules.CaptchaVerifierFilter"&gt;
  
   &lt;beans:property name="useProxy" value="false"/&gt;
   &lt;beans:property name="proxyPort" value=""/&gt;
   &lt;beans:property name="failureUrl" value="/login?error"/&gt;
   &lt;beans:property name="captchaCaptureFilter" ref="captchaCaptureFilter"/&gt;
   &lt;beans:property name="privateKey" value="6LeTVQcTAAAAAI_NiPSYXAix-OKYp4KcC0aQ5ce2"/&gt;
  
   &lt;/beans:bean&gt;
  
  
      &lt;authentication-manager&gt;
          &lt;authentication-provider ref="authenticationProvider" /&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>Any help suggestion is highly appreciated</p>