title: Problems setting up Spring Security in Grails
body: <p>I am a bit stuck trying to set up Spring Integration Plugin into my Grails app (2.3.4. version).</p>
  
  <p><strong>BuildConfig.groovy</strong></p>
  
  <pre><code>compile ":spring-security-core:2.0-RC2"
  </code></pre>
  
  <p>After launching the s2-quickstart script, I have generated BOUser, BORole, BOUserRole and BORequestMap classes.</p>
  
  <p><strong>Config.groovy</strong></p>
  
  <pre><code>grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.my.example.BOUser'
  grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.my.example.BOUserRole'
  grails.plugin.springsecurity.authority.className = 'com.my.example..BORole'
  grails.plugin.springsecurity.requestMap.className = 'com.my.example.BORequestMap'
  grails.plugins.springsecurity.portMapper.httpPort = '8080'
  grails.plugins.springsecurity.portMapper.httpsPort = '8443'
  grails.plugins.springsecurity.rejectIfNoRule = true
  grails.plugin.springsecurity.securityConfigType = 'Requestmap'
  grails.plugin.springsecurity.roleHierarchy = '''
                                             ROLE_SUPER_ADMIN &gt; ROLE_ADMIN
                                             ROLE_ADMIN &gt; ROLE_USER
                                            '''
  </code></pre>
  
  <p><strong>Bootstrap.groovy</strong></p>
  
  <pre><code>def customer = new Customer(name: "myCustomer", web:"www.myCustomer.com").save()
  
  def superAdminUser = new BOUser(username:"superAdmin", password:"1234", customer: customer)
  def adminUser = new BOUser(username:"admin", password:"1234", customer: customer)
  def user = new BOUser(username:"user", password:"1234", customer: customer)
  
  def roleSuperAdminUser = new BORole(authority:"ROLE_SUPER_ADMIN")
  def roleAdminUser = new BORole(authority:"ROLE_ADMIN")
  def roleUser = new BORole(authority:"ROLE_USER")
  
  superAdminUser.save();
  adminUser.save();
  user.save();
  
  roleSuperAdminUser.save()
  roleAdminUser.save()
  roleUser.save()
  
  def superAdminRole = new BOUserRole(BOUser: superAdminUser, BORole:roleSuperAdminUser)
  def adminRole = new BOUserRole(BOUser: adminUser, BORole:roleAdminUser)
  def userRole = new BOUserRole(BOUser: user, BORole:roleUser)
  
  superAdminRole.save();
  adminRole.save();
  userRole.save();
  
  for (String url in [
      '/', 
      '/index', 
      '/index.gsp', 
      '/**/favicon.ico',
      '/**/js/**', 
      '/**/css/**', 
      '/**/images/**',
      '/login', 
      '/login.*', 
      '/login/*',
      '/logout', 
      '/logout.*', 
      '/logout/*']) 
  {
      new BORequestMap(url: url, configAttribute: 'permitAll').save()
  }
  </code></pre>
  
  <p>I run the app and the login page is shown but I cannot authenticate with any user, showing always the same message: "Sorry, we were not able to find a user with that username and password."</p>
  
  <p>My database is being filled correctly with url mappings, users, roles and user-role relations</p>
  
  <p><strong>LOG</strong></p>
  
  <pre><code>|Loading Grails 2.3.4
  |Configuring classpath
  .
  |Environment set to development
  .................................
  |Packaging Grails application
  ................................................
  |Running Grails application
  Configuring Spring Security Core ...
  ... finished configuring Spring Security Core
  2014-02-07 17:58:56,816 [localhost-startStop-1] DEBUG hierarchicalroles.RoleHierarchyImpl  - setHierarchy() - The following role hierarchy was set: 
                                             ROLE_SUPER_ADMIN &gt; ROLE_ADMIN
                                             ROLE_ADMIN &gt; ROLE_USER
  
  2014-02-07 17:58:56,818 [localhost-startStop-1] DEBUG hierarchicalroles.RoleHierarchyImpl  - buildRolesReachableInOneStepMap() - From role ROLE_SUPER_ADMIN one can reach role ROLE_ADMIN in one step.
  2014-02-07 17:58:56,818 [localhost-startStop-1] DEBUG hierarchicalroles.RoleHierarchyImpl  - buildRolesReachableInOneStepMap() - From role ROLE_ADMIN one can reach role ROLE_USER in one step.
  2014-02-07 17:58:56,818 [localhost-startStop-1] DEBUG hierarchicalroles.RoleHierarchyImpl  - buildRolesReachableInOneOrMoreStepsMap() - From role ROLE_ADMIN one can reach [ROLE_USER] in one or more steps.
  2014-02-07 17:58:56,818 [localhost-startStop-1] DEBUG hierarchicalroles.RoleHierarchyImpl  - buildRolesReachableInOneOrMoreStepsMap() - From role ROLE_SUPER_ADMIN one can reach [ROLE_ADMIN, ROLE_USER] in one or more steps.
  2014-02-07 17:58:57,060 [localhost-startStop-1] DEBUG intercept.FilterSecurityInterceptor  - Validated configuration attributes
  2014-02-07 17:59:00,491 [localhost-startStop-1] INFO  web.DefaultSecurityFilterChain  - Creating filter chain: Ant [pattern='/**'], [org.springframework.security.web.context.SecurityContextPersistenceFilter@17f73aeb, grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter@683d2697, grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter@6b0b8f8, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3c3fa536, grails.plugin.springsecurity.web.filter.GrailsRememberMeAuthenticationFilter@76779b20, grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter@26698ea3, org.springframework.security.web.access.ExceptionTranslationFilter@5c138308, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4ffb172]
  |Server running. Browse to http://localhost:8080/playtheguru_bo
  ....2014-02-07 17:59:05,054 [http-bio-8080-exec-4] DEBUG util.AntPathRequestMatcher  - Request '/j_spring_security_check' matched by universal pattern '/**'
  2014-02-07 17:59:05,055 [http-bio-8080-exec-4] DEBUG web.FilterChainProxy  - /j_spring_security_check at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  2014-02-07 17:59:05,056 [http-bio-8080-exec-4] DEBUG context.HttpSessionSecurityContextRepository  - No HttpSession currently exists
  2014-02-07 17:59:05,056 [http-bio-8080-exec-4] DEBUG context.HttpSessionSecurityContextRepository  - No SecurityContext was available from the HttpSession: null. A new one will be created.
  2014-02-07 17:59:05,057 [http-bio-8080-exec-4] DEBUG web.FilterChainProxy  - /j_spring_security_check at position 2 of 8 in additional filter chain; firing Filter: 'MutableLogoutFilter'
  2014-02-07 17:59:05,058 [http-bio-8080-exec-4] DEBUG web.FilterChainProxy  - /j_spring_security_check at position 3 of 8 in additional filter chain; firing Filter: 'RequestHolderAuthenticationFilter'
  2014-02-07 17:59:05,059 [http-bio-8080-exec-4] DEBUG authentication.ProviderManager  - Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
  2014-02-07 17:59:05,170 [http-bio-8080-exec-4] DEBUG rememberme.TokenBasedRememberMeServices  - Interactive login attempt was unsuccessful.
  2014-02-07 17:59:05,170 [http-bio-8080-exec-4] DEBUG rememberme.TokenBasedRememberMeServices  - Cancelling cookie
  2014-02-07 17:59:05,175 [http-bio-8080-exec-4] DEBUG web.DefaultRedirectStrategy  - Redirecting to '/playtheguru_bo/login/authfail?login_error=1'
  2014-02-07 17:59:05,175 [http-bio-8080-exec-4] DEBUG context.HttpSessionSecurityContextRepository  - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
  2014-02-07 17:59:05,175 [http-bio-8080-exec-4] DEBUG context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed
  2014-02-07 17:59:05,179 [http-bio-8080-exec-5] DEBUG util.AntPathRequestMatcher  - Request '/login/authfail' matched by universal pattern '/**'
  2014-02-07 17:59:05,179 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  2014-02-07 17:59:05,180 [http-bio-8080-exec-5] DEBUG context.HttpSessionSecurityContextRepository  - HttpSession returned null object for SPRING_SECURITY_CONTEXT
  2014-02-07 17:59:05,180 [http-bio-8080-exec-5] DEBUG context.HttpSessionSecurityContextRepository  - No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@3253d487. A new one will be created.
  2014-02-07 17:59:05,180 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 2 of 8 in additional filter chain; firing Filter: 'MutableLogoutFilter'
  2014-02-07 17:59:05,180 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 3 of 8 in additional filter chain; firing Filter: 'RequestHolderAuthenticationFilter'
  2014-02-07 17:59:05,180 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  2014-02-07 17:59:05,181 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 5 of 8 in additional filter chain; firing Filter: 'GrailsRememberMeAuthenticationFilter'
  2014-02-07 17:59:05,182 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 6 of 8 in additional filter chain; firing Filter: 'GrailsAnonymousAuthenticationFilter'
  2014-02-07 17:59:05,183 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
  2014-02-07 17:59:05,183 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
  2014-02-07 17:59:06,483 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - Secure object: FilterInvocation: URL: /login/authfail?login_error=1; Attributes: [permitAll]
  2014-02-07 17:59:06,483 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - Previously Authenticated: grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@f23f6da8: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; 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@fffbcba8: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 97E07CDE56C15DC3639B2E0E76F7C41E; Granted Authorities: ROLE_ANONYMOUS
  2014-02-07 17:59:06,484 [http-bio-8080-exec-5] DEBUG hierarchicalroles.RoleHierarchyImpl  - getReachableGrantedAuthorities() - From the roles [ROLE_ANONYMOUS] one can reach [ROLE_ANONYMOUS] in zero or more steps.
  2014-02-07 17:59:06,491 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - Authorization successful
  2014-02-07 17:59:06,491 [http-bio-8080-exec-5] DEBUG intercept.FilterSecurityInterceptor  - RunAsManager did not change Authentication object
  2014-02-07 17:59:06,492 [http-bio-8080-exec-5] DEBUG web.FilterChainProxy  - /login/authfail?login_error=1 reached end of additional filter chain; proceeding with original chain
  2014-02-07 17:59:06,646 [http-bio-8080-exec-5] DEBUG access.ExceptionTranslationFilter  - Chain processed normally
  2014-02-07 17:59:06,647 [http-bio-8080-exec-5] DEBUG context.HttpSessionSecurityContextRepository  - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
  2014-02-07 17:59:06,647 [http-bio-8080-exec-5] DEBUG context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG util.AntPathRequestMatcher  - Request '/login/auth' matched by universal pattern '/**'
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 1 of 8 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG context.HttpSessionSecurityContextRepository  - HttpSession returned null object for SPRING_SECURITY_CONTEXT
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG context.HttpSessionSecurityContextRepository  - No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@3253d487. A new one will be created.
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 2 of 8 in additional filter chain; firing Filter: 'MutableLogoutFilter'
  2014-02-07 17:59:06,652 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 3 of 8 in additional filter chain; firing Filter: 'RequestHolderAuthenticationFilter'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 4 of 8 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 5 of 8 in additional filter chain; firing Filter: 'GrailsRememberMeAuthenticationFilter'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 6 of 8 in additional filter chain; firing Filter: 'GrailsAnonymousAuthenticationFilter'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 7 of 8 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG intercept.FilterSecurityInterceptor  - Secure object: FilterInvocation: URL: /login/auth?login_error=1&amp;format=; Attributes: [permitAll]
  2014-02-07 17:59:06,653 [http-bio-8080-exec-6] DEBUG intercept.FilterSecurityInterceptor  - Previously Authenticated: grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@f23f6da8: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; 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@fffbcba8: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: 97E07CDE56C15DC3639B2E0E76F7C41E; Granted Authorities: ROLE_ANONYMOUS
  2014-02-07 17:59:06,654 [http-bio-8080-exec-6] DEBUG hierarchicalroles.RoleHierarchyImpl  - getReachableGrantedAuthorities() - From the roles [ROLE_ANONYMOUS] one can reach [ROLE_ANONYMOUS] in zero or more steps.
  2014-02-07 17:59:06,654 [http-bio-8080-exec-6] DEBUG intercept.FilterSecurityInterceptor  - Authorization successful
  2014-02-07 17:59:06,654 [http-bio-8080-exec-6] DEBUG intercept.FilterSecurityInterceptor  - RunAsManager did not change Authentication object
  2014-02-07 17:59:06,655 [http-bio-8080-exec-6] DEBUG web.FilterChainProxy  - /login/auth?login_error=1&amp;format= reached end of additional filter chain; proceeding with original chain
  2014-02-07 17:59:07,940 [http-bio-8080-exec-6] DEBUG context.HttpSessionSecurityContextRepository  - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
  2014-02-07 17:59:07,941 [http-bio-8080-exec-6] DEBUG access.ExceptionTranslationFilter  - Chain processed normally
  2014-02-07 17:59:07,941 [http-bio-8080-exec-6] DEBUG context.SecurityContextPersistenceFilter  - SecurityContextHolder now cleared, as request processing completed
  </code></pre>
  
  <p>Anyone can help?</p>
  
  <p>Thanks!</p>