Search code examples
grailsspring-security

Grails 3.2.9 with Spring Security plugin 3.1.2 got "too many redirects" with default configuration


Created a new app, added compile 'org.grails.plugins:spring-security-core:3.1.2' and did:

grails s2-quickstart com.cabolabs.security User Role RequestMap

Then grails run-app.

  1. Trying to access the /dbconsole, redirects to /login/auth
  2. /login/auth got "localhost redirected you too many times." ERR_TOO_MANY_REDIRECTS

Is this the expected behavior or a bug form the plugin?

The doc, on the install and configuration section, doesn't mention anything about this https://grails-plugins.github.io/grails-spring-security-core/v3/#configuration

UPDATE

Found on the documentation, section 5.3 (https://grails-plugins.github.io/grails-spring-security-core/v3/) the initial RequestMap that should be added.

for (String url in [
      '/', '/error', '/index', '/index.gsp', '/**/favicon.ico', '/shutdown',
      '/**/js/**', '/**/css/**', '/**/images/**',
      '/login', '/login.*', '/login/*',
      '/logout', '/logout.*', '/logout/*']) {
   new Requestmap(url: url, configAttribute: 'permitAll').save()
}

Used that in the Bootstrap.groovy, and still got the "too many redirects".

Also, can't view the /dbconsole to check the database because it's blocked by the plugin.


Solution

  • The solution proposed on GitHub and I tested it to work is to call clearCachedRequestmaps after creating the request map instances.

      for (String url in [
          '/', '/error', '/index', '/index.gsp', '/**/favicon.ico', '/shutdown',
          '/**/js/**', '/**/css/**', '/**/images/**',
          '/login', '/login.*', '/login/*',
          '/logout', '/logout.*', '/logout/*']) {
       new RequestMap(url: url, configAttribute: 'permitAll').save()
    }
    
       springSecurityService.clearCachedRequestmaps()