【问题标题】:Ignore WebSocket connection in Spring Security SavedRequest忽略 Spring Security SavedRequest 中的 WebSocket 连接
【发布时间】:2013-05-15 21:21:08
【问题描述】:

我有一个带有 spring-security-core 插件和 Atmosphere 框架的 Grails 应用程序。

如果我从已打开 WebSocket 连接的页面注销,则 Spring Security 会将 WebSocket 连接的 URL 保留为 SavedRequest。

DEBUG savedrequest.HttpSessionRequestCache  - DefaultSavedRequest added to Session: DefaultSavedRequest[http://localhost:8080/formx/formX/update]
DEBUG savedrequest.HttpSessionRequestCache  - DefaultSavedRequest added to Session: DefaultSavedRequest[http://localhost:8080/formx/formX/notifications/?X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=b5d8fde4-d950-41fd-9b49-02e06799a36f&conversationId=988080042]

日志中的第一个条目具有 SavedRequest 的正确值,但不知何故它被 Atmosphere WebSocket 连接覆盖。

如何告诉 Spring Security 不使用 Atmosphere WebSocket 连接作为 SavedRequest?

我想我可以使用一些Atmosphere Protocol Specific Header 来区分连接。

【问题讨论】:

  • 在 Atmosphere 处理程序上添加 'none'security 怎么样:
  • 您好,正在尝试清理未答复的内容。你解决了吗?也许你可以回答你自己的问题。
  • 不,很遗憾我没有解决方案。

标签: grails spring-security websocket atmosphere


【解决方案1】:

在 Java 配置中,您可以设置 RequestMatcher - 这很容易。

在 WebSecurityConfigurerAdapter 中:

protected void configure(HttpSecurity http) {
    HttpSessionRequestCache cache = new HttpSessionRequestCache(); //this one is used by default
    cache.setRequestMatcher(AnyRequestMatcher.INSTANCE); //change the request matcher, so it do not match your Atmosphere requests
    http.requestCache().requestCache(cache);
}

【讨论】:

    猜你喜欢
    • 2021-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多