Grails4会话注册表为空
升级到Grails4时,sessionRegistry.getAllPrincipal()始终为空 resources.groovy中最初的Springbean是Grails4会话注册表为空,grails,spring-security,grails-4,Grails,Spring Security,Grails 4,升级到Grails4时,sessionRegistry.getAllPrincipal()始终为空 resources.groovy中最初的Springbean是 sessionRegistry(SessionRegistryImpl) concurrentSessionFilter(ConcurrentSessionFilter){ sessionRegistry = sessionRegistry expiredUrl = '/login' } 由于这不再有效,我尝试将re
sessionRegistry(SessionRegistryImpl)
concurrentSessionFilter(ConcurrentSessionFilter){
sessionRegistry = sessionRegistry
expiredUrl = '/login'
}
由于这不再有效,我尝试将resources.groovy更新为
sessionRegistry(SessionRegistryImpl)
registerSessionAuthenticationStrategy(RegisterSessionAuthenticationStrategy, ref(sessionRegistry))
sessionFixationProtectionStrategy(SessionFixationProtectionStrategy)
concurrentSessionControlAuthenticationStrategy(ConcurrentSessionControlAuthenticationStrategy, ref(sessionRegistry)){
maximumSessions=1
exceptionIfMaximumExceeded=true
}
compositeSessionAuthenticationStrategy(CompositeSessionAuthenticationStrategy,
[ref(registerSessionAuthenticationStrategy),ref(sessionFixationProtectionStrategy),ref(concurrentSessionControlAuthenticationStrategy)])
所有这些bean都来自org.springframework.security.web.authentication.session包
我还向grails.plugin.springsecurity.providerNames添加了名称
DaoAuthenticationProvider由自定义身份验证提供程序扩展。登录和注销工作正常,但主体从未在升级的应用程序中注册。是否需要手动注册它们(sessionRegistry.registerNewSession())
旧的答案是使用grails安装模板,然后在src/templates/war中编辑web.xml。然而,在Grails4中,安装模板没有生成war/web.xml
我尝试将其添加到/WEB-INF/WEB.xml,但仍然没有成功。我认为您缺少sessionAuthenticationStragegy bean定义,请尝试删除compositeSessionAuthenticationStrategy行,并将其替换为:
sessionAuthenticationStrategy(CompositeSessionAuthenticationStrategy,[ref('concurrentSessionControlAuthenticationStrategy')、ref('sessionFixationProtectionStrategy')、ref('registerSessionAuthenticationStrategy'))
这是我看到的您的代码和我的代码之间的唯一区别,我的代码正在使用Grails4