带Grails Spring Security Core 2.0RC4的Requestmap重定向循环 [英] Redirect Loop with Requestmap with grails spring security core 2.0RC4

查看:307
本文介绍了带Grails Spring Security Core 2.0RC4的Requestmap重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面对Grails 2.4.4面对Failed to load resource: net::ERR_TOO_MANY_REDIRECTS.我在com.usermanagement.auth程序包中有UserRoleRequestmap(它们是用s2-quickstart生成的). Requestmap,用户和角色似乎存储在数据库中(我正在使用mysql).

I have been facing Failed to load resource: net::ERR_TOO_MANY_REDIRECTS with grails 2.4.4. I have User, Role and Requestmap in com.usermanagement.auth package(those were generated with s2-quickstart). Requestmaps, users and roles seem to be stored in the database(I am using mysql).

BuildConfig.groovy

编译:spring-security-core:2.0-RC4"

compile ":spring-security-core:2.0-RC4"

Bootstrap.groovy 初始化方法上

        User admin = new User(username:'admin', password:'secret', enabled:true).save()
        User john = new User(username:'john', password:'secret', enabled:true).save()
        User jane = new User(username:'jane', password:'secret', enabled:true).save()
        Role royalty = new Role(authority: 'ROLE_ROYALTY').save()
        Role common = new Role(authority: 'ROLE_COMMON').save()
        UserRole.create(admin, royalty)
        UserRole.create(admin, common)
        UserRole.create(john, common)

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

        new Requestmap(url: '/*', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save();
        new Requestmap(url: '/dbconsole/**', configAttribute: 'permitAll').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();
        new Requestmap(url: '/', configAttribute: 'permitAll').save();

Config.groovy

// Added by the Spring Security Core plugin:
grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.usermanagement.auth.User'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.usermanagement.auth.UserRole'
grails.plugin.springsecurity.authority.className = 'com.usermanagement.auth.Role'
grails.plugin.springsecurity.requestMap.className = 'com.usermanagement.auth.Requestmap'
grails.plugin.springsecurity.securityConfigType = 'Requestmap'
grails.plugin.springsecurity.rejectIfNoRule = true

每当我尝试访问localhost:8080/appname/时,都会在重定向到http://localhost:8080/appname/login/auth后导致太多重定向错误.是什么导致此问题?我什至无法访问dbconsole.

Whenever I try to access localhost:8080/appname/, this results in too many redirects error after being redirected to http://localhost:8080/appname/login/auth. What may be causing this issue? I am even unable to access dbconsole.

推荐答案

事实证明,这是 https://jira.grails.org/browse/GPSPRINGSECURITYCORE-312 . Spring Security Core无法加载Grails 2.4.4中存储在数据库中的RequestMap.我按照链接中提到的方法进行了工作;我基本上将休眠插件从4.3.6.1降级到4.3.5.5.提到了其他解决方法.但这对我有用.

As it turns out, this had been a bug as mentioned in https://jira.grails.org/browse/GPSPRINGSECURITYCORE-312. Spring Security Core is unable to load RequestMaps stored in the database in Grails 2.4.4. I followed a work around mentioned in the link; I basically downgraded the hibernate plugin from 4.3.6.1 to 4.3.5.5. There are other workaround mentioned. But this worked for me.

// runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17"

这篇关于带Grails Spring Security Core 2.0RC4的Requestmap重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆