Grails spring security fails to present the login page due to a redirect loop

拥有回忆 提交于 2019-11-29 16:40:44

You're using Requestmap as security config type, your controllerAnnotations.staticRules does not have any effect.

You need configure rules in RequestMap table, and enable your login controller and public pages to anonymous can access without login like:

    new Requestmap(url: '/*', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();
    new Requestmap(url: '/logout/**', configAttribute: 'IS_AUTHENTICATED_REMEMBERED,IS_AUTHENTICATED_FULLY').save();
    new Requestmap(url: '/login/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
    new Requestmap(url: '/index/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();
Aadil Masavir

Thanks Mr Ignacio Ocampo for your help.

These lines have to be added in bootstrap.groovy.

Thanks Alot.

class BootStrap {

    def springSecurityService
    def grailsApplication

    def init = { servletContext ->

        println "In bootstrap Init"

        //Added so that these urls can be visible to everyone
        new Requestmap(url: '/*', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();
        new Requestmap(url: '/logout/**', configAttribute: 'IS_AUTHENTICATED_REMEMBERED,IS_AUTHENTICATED_FULLY').save();
        new Requestmap(url: '/login/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
        new Requestmap(url: '/index/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();


        println 'Bootstrap init done'


    }


    def destroy = {

    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!