Spring-Security:如何使用WebSocket-scoped bean实现身份验证

时间:2016-07-29 16:52:29

标签: spring spring-security spring-websocket

尝试解决How to combine Spring Security and js sockjs-client,我想实现在非经过身份验证的https会话上运行的websocket会话的身份验证(因为sockjs-client限制)。

我正在思考:

  1. 在CONNECT消息上,传递凭据。拦截器检查凭据,并在WebSocket范围的bean中设置身份验证主体。 [1]
  2. 在其他请求期间,拦截器检查WebSocket范围的bean,并在SecurityContext中设置Authentication对象,以便ChannelSecurityInterceptor可以检索它。
  3. 目前我无法在spring ChannelSecurityInterceptor之前调用拦截器,我不确定WebSocket-scoped bean是否可用于保存主体。

    或者我应该使用DefaultHandshakeHandler.determineUser()根据握手请求中的信息设置主体?这可以与ChannelSecurityInterceptor一起使用吗?

    [1] http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#websocket-stomp-websocket-scope

0 个答案:

没有答案