title: Authentication failed - Bad credentials in grails spring security
body: <p>I have created my users and roles in Bootstrap.groovy.</p>
  
  <pre><code>def user = new User(username:"name", password:"pass",email:"email@gmail.rr",enabled:true).save()
  </code></pre>
  
  <p>I have checked the usernames and passwords for each one directly in the database. 
  I have even removed the encoding for testing purposes.
  However, I get this when I try to login (there is some additional logging added by me)</p>
  
  <blockquote>
    <p>2014-01-27 22:49:04,480 [http-bio-8090-exec-3] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    2014-01-27 22:49:04,480 [http-bio-8090-exec-4] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    2014-01-27 23:06:19,654 [http-bio-8090-exec-7] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    2014-01-27 23:06:19,833 [http-bio-8090-exec-8] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    authentication
    grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc4a600: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: <strong>grails.anonymous.user</strong>; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 951C58071D49B3E3AB6D55C158C46B43; Granted Authorities: ROLE_ANONYMOUS
    is NOT logged in
    2014-01-27 23:06:29,147 [http-bio-8090-exec-9] DEBUG authentication.RequestHolderAuthenticationFilter  - Request is to process authentication
    2014-01-27 23:06:30,115 [http-bio-8090-exec-9] DEBUG authentication.RequestHolderAuthenticationFilter  - Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
    2014-01-27 23:06:30,115 [http-bio-8090-exec-9] DEBUG authentication.RequestHolderAuthenticationFilter  - Updated SecurityContextHolder to contain null Authentication
    2014-01-27 23:06:30,115 [http-bio-8090-exec-9] DEBUG authentication.RequestHolderAuthenticationFilter  - Delegating to authentication failure handler grails.plugin.springsecurity.web.authentication.AjaxAwareAuthenticationFailureHandler@df9533
    2014-01-27 23:06:30,116 [http-bio-8090-exec-9] DEBUG authentication.AjaxAwareAuthenticationFailureHandler  - Redirecting to /login/authfail?login_error=1
    2014-01-27 23:06:30,165 [http-bio-8090-exec-10] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    authentication failed!!!!
    2014-01-27 23:06:30,235 [http-bio-8090-exec-10] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: '{0}'
    authentication
    grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc4a600: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: <strong>grails.anonymous.user</strong>; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 127.0.0.1; SessionId: 951C58071D49B3E3AB6D55C158C46B43; Granted Authorities: ROLE_ANONYMOUS
    is NOT logged in</p>
  </blockquote>
  
  <p>What do you understand from this stacktrace please? If any more information is needed, I would provide it with no hesitation :)</p>
  
  <p>From what I see in the logs, when I try to login with the administrator user which I have created and verified in the database, spring security is trying to log in with the anonymous user who has no access to these pages
  Here is some more spring security config </p>
  
  <pre><code>    grails.plugin.springsecurity.controllerAnnotations.staticRules = [
  ]
  grails.plugin.springsecurity.interceptUrlMap = [
      '/candidate/*': ['ROLE_ADMIN'],
  
   ]
  </code></pre>