Spring Security RememberMe 成功处理程序或 url 过滤

发布于 2024-12-04 06:48:28 字数 538 浏览 4 评论 0原文

我正在使用带有登录页面和记住我过滤器的 Spring Security。记住我过滤可以发生在应用程序的任何页面上。

但当用户从登录页面和 cookie 进行身份验证时,我希望有相同的行为:

  • 我想在会话中设置一些用户信息
  • 我想将用户重定向到主页(always-use-default-target =“true”) ")

我已经看到 Spring Security 自 3.1.0 起就支持 Remember-me 标签的成功处理程序 (https://jira.springsource.org/browse/SEC-1603)。

对我来说另一个解决方案是限制 Remember-me 过滤器的 URL,例如拦截 URL。我只允许在默认或主页 URL 上进行记住我过滤。

在 3.1.0 版本之前,是否有标准方法来限制“记住我”过滤器的 URL 或在 cookie 身份验证后重定向用户?

I am using Spring Security with a login page and a remember-me filter. The remember-me filtering can happen on any page of the application.

But I want the same behaviour both when the user is authenticated from login page and from the cookie:

  • I want to set some user information in session
  • I want to redirect the user to the home page (always-use-default-target="true")

I have seen that the success-handler for the remember-me tag is supported by Spring Security since the 3.1.0 (https://jira.springsource.org/browse/SEC-1603).

Another solution for me would be to restrict the URL for the remember-me filter, like the intercept-url. I would allow the remember-me filtering only on the default or home page URL.

Is there a standard way to restrict the URL for the remember-me filter or to redirect the user after cookie authentication before the version 3.1.0?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳 2024-12-11 06:48:28

当然 - 子类 RememberMeAuthenticationFilter 并覆盖 doFilter()。如果请求是针对主页,则调用 super.doFilter(),否则调用 chain.doFilter()。

Sure - subclass RememberMeAuthenticationFilter and override doFilter(). If the request is for the home page call super.doFilter(), otherwise call chain.doFilter().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文