有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Camunda BPM:CSRFPreventionFilter:无效的HTTP头令牌

我从camunda BPM开始,所以我使用https://start.camunda.com/来创建camunda spring boot应用程序。我已经创建了管理员用户和虚拟/虚拟凭据,我有kepy spring安全选项作为off,作为start

初学者设置一览表: enter image description here

当我启动应用程序时,每当我使用creds时,我都会遇到以下错误:

Login Failed :
CSRFPreventionFilter: Invalid HTTP Header Token

我在应用程序中没有看到任何相关设置。yml


共 (1) 个答案

  1. # 1 楼答案

    看起来Camunda的给定版本中有一个bug。为了手动抑制CSRFFilter,我添加了以下配置。在那之后,它现在开始工作了

    package com.example.workflow;
    
    import org.springframework.boot.web.servlet.ServletContextInitializer;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    @Configuration
    public class CsrfAutoConfiguration {
        private static final String CSRF_PREVENTION_FILTER = "CsrfPreventionFilter";
        /**
         * Overwrite csrf filter from Camunda configured here
         * org.camunda.bpm.spring.boot.starter.webapp.CamundaBpmWebappInitializer
         * org.camunda.bpm.spring.boot.starter.webapp.filter.SpringBootCsrfPreventionFilter
         * Is configured with basically a 'no-op' filter
         */
        @Bean
        public ServletContextInitializer csrfOverwrite() {
            return servletContext -> servletContext.addFilter(CSRF_PREVENTION_FILTER, (request, response, chain) -> chain.doFilter(request, response));
        }
    }
    

    礼节: https://forum.camunda.org/t/how-to-disable-csrfpreventionfilter/13095/8