如何更改Grails Spring Security Cookie路径 [英] How to change Grails Spring Security Cookie Path

查看:217
本文介绍了如何更改Grails Spring Security Cookie路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个使用spring security的grails应用程式:

I've got two grails applications using spring security:


  • Core

  • 用户和角色表映射到Core db表)

我想使用记住我功能使用单点登录功能。问题是,cookies存储在不同的路径/ Core和/ Module,我猜这是它不工作的原因。

I want to have a single sign on functionality using "remember me". The problem is that the cookies are stored in different paths "/Core" and "/Module" which I'm guessing is the reason why it isn't working.

是否有人知道如何将Cookie路径更改为/?

Does anyone know how to change the cookie path to be "/"?

注意


  • 我需要更改Spring Security或Tomcat服务器配置(使用intellij)

  • 我想避免设置CAS服务器

感谢任何帮助非常感谢

推荐答案

当remember-me过滤器创建remember-me cookie时,它将cookie路径设置为获取的上下文路径从请求对象(参见相关源代码)。如果要自定义此行为,您需要覆盖 setCookie() cancelCookie()方法您的应用程序使用的记住我服务实现( TokenBasedRememberMeServices PersistentTokenBasedRememberMeServices )并配置 RememberMeAuthenticationFilter 以使用您的自定义实现。

When the remember-me filter creates the remember-me cookie, it sets the cookie path to the context path obtained from the request object (see related source code here). If you want to customize this behavior, you'll need to override the setCookie() and cancelCookie() methods of the remember-me service implementation your application uses (either TokenBasedRememberMeServices or PersistentTokenBasedRememberMeServices) in a subclass, and configure the RememberMeAuthenticationFilter to use your custom implementation.

这篇关于如何更改Grails Spring Security Cookie路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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