【问题标题】:No valid crumb was included in the request - Jenkins 403请求中没有包含有效的面包屑 - Jenkins 403
【发布时间】:2019-11-19 15:50:45
【问题描述】:

我的 Crumb.sh 文件是:

    crumb=$(curl -u "jenkins:pwd" -s 'http://yuvi_jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
    echo $crumb
    curl -u "jenkins:pwd" -H "$crumb" -X POST http://yuvi_jenkins:8080/job/ansible-project/build?delay=0sec

我得到的输出是:

Jenkins-Crumb:d3950e9f61bc9dd88fba532c17dba1ce220be11b92d78e720464afd38021a3fb


<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /job/ansible-project/build. Reason:
<pre> No valid crumb was included in the request</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>

我尝试过的解决方案:

1) Probably you are accessing jenkins by proxy server, please do following

    Go to "Global Security Settings"
    Check "Enables the Compatibilty Mode for proxies".
    Restart

2) To resolve this issue I unchecked "Prevent Cross Site Request Forgery exploits" in jenkins.com/configureSecurity section. 

我已经尝试了上述解决方案,但仍然遇到同样的错误。

【问题讨论】:

    标签: jenkins continuous-integration jenkins-pipeline ubuntu-16.04 jenkins-cli


    【解决方案1】:

    根据 Jenkins 文档 here,碎屑现在仅对创建它们的 Web 会话有效。为了解决这个问题,您可以在发出 crumb 请求时存储 cookie,然后在进行后续 API 调用时使用这些存储的 cookie。所以你的脚本会变成:

    crumb=$(curl --cookie-jar ./cookie -u "jenkins:pwd" -s 'http://yuvi_jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
    curl --cookie ./cookie -u "jenkins:pwd" -H "$crumb" -X POST http://yuvi_jenkins:8080/job/ansible-project/build?delay=0sec
    

    或者,我链接的文档建议将系统属性 hudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID 设置为 true,或使用 Strict Crumb Issuer Plugin 更改 crumb 验证以使用时间而不是会话 ID

    感谢https://github.com/spinnaker/spinnaker/issues/2067#issuecomment-544993648帮我解决同样的问题

    【讨论】:

      猜你喜欢
      • 2019-04-03
      • 1970-01-01
      • 2021-05-22
      • 2017-10-19
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多