【问题标题】:Disable CSRF protection in websockets using XML configuration使用 XML 配置禁用 websocket 中的 CSRF 保护
【发布时间】:2017-04-16 14:53:24
【问题描述】:

我想使用 Spring XML 配置禁用 websocket CSRF 保护。

我知道可以using Java configuration:

@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {

    ...

    @Override
    protected boolean sameOriginDisabled() {
        return true;
    }
}

...但是我怎样才能在 XML 配置中做同样的事情呢?

【问题讨论】:

    标签: java spring configuration websocket csrf-protection


    【解决方案1】:

    你必须把它作为一个属性放在你的 websocket-message-broker 元素上:

    <websocket-message-broker same-origin-disabled="true">...</websocket-message-broker>
    

    【讨论】:

      【解决方案2】:

      您可以使用 XML 配置文件并添加:

      <http>
        <!-- ... -->
        <csrf disabled="true"/>
      </http>
      

      相当于java:

      protected void configure(HttpSecurity http) throws Exception {
        http
        .csrf().disable();
      }
      

      【讨论】:

      • 我相信提问者对 Web 套接字安全而不是 http 安全感兴趣
      猜你喜欢
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 2012-04-08
      • 2011-03-12
      • 2011-11-27
      • 2010-12-19
      • 1970-01-01
      • 2015-12-01
      相关资源
      最近更新 更多