首页 > 解决方案 > Camunda BPM:CSRFPreventionFilter:无效的 HTTP 标头令牌

问题描述

我从 camunda BPM 开始,所以我使用https://start.camunda.com/创建 camunda spring boot 应用程序。我已经创建了具有虚拟/虚拟凭据的管理员用户,我将弹簧安全选项保持在与开始一样的位置。

入门设置一目了然: 在此处输入图像描述

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

Login Failed :
CSRFPreventionFilter: Invalid HTTP Header Token

我在 application.yml 中看不到任何相关设置

标签: javaspringspring-bootcamundabusiness-process-management

解决方案


看起来在给定版本的 Camunda 中存在错误。为了手动抑制 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


推荐阅读