Could not verify the provided CSRF token because your session was not found in spring security

前端 未结 7 2146
甜味超标
甜味超标 2020-12-15 03:09

I am using spring security along with java config

@Override
protected void configure(HttpSecurity http) throws Exception { 
    http
    .authorizeRequests()         


        
7条回答
  •  暖寄归人
    2020-12-15 04:00

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

    @Configuration
    public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
    
        ...
    
        // Determines if a CSRF token is required for connecting. This protects against remote
        // sites from connecting to the application and being able to read/write data over the
        // connection. The default is false (the token is required).
        @Override
        protected boolean sameOriginDisabled() {
            return true;
        }
    }
    

    source: WebSocket Security: Disable CSRF within WebSockets

提交回复
热议问题