Как настроить Spring Web Security и Spring WebSock Secruity вместе? - PullRequest
0 голосов
/ 23 января 2020

Я пытаюсь настроить веб-безопасность и безопасность веб-сокета вместе, используя этот класс:

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

        http.csrf()
                // ignore our stomp endpoints since they are protected using Stomp headers
                .ignoringAntMatchers("/ws/**")
                .and()
                .headers()
                // allow same origin to frame our site to support iframe SockJS
                .frameOptions().sameOrigin()
                .and()
                .authorizeRequests();

        http.cors().
                and().csrf().disable().
                authorizeRequests()
                .antMatchers("/users/**").permitAll()
                .antMatchers("/roles/**").permitAll()
                .anyRequest().authenticated()
                .and()
                .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);

        http.addFilterAfter(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
    }

Я использую STOMP withSock JS, но я всегда получаю эту ошибку : nested exception is org.springframework.security.web.csrf.MissingCsrfTokenException: Could not verify the provided CSRF token because your session was not found.

я что-то испортил? Я отключил CSRF.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...