Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin can not connect to Jenkins anmyore with: [Fail] CSRF enabled -> Missing or bad crumb data #512

Closed
ststoessel opened this issue Aug 22, 2023 · 17 comments

Comments

@ststoessel
Copy link

ststoessel commented Aug 22, 2023

The Jenkins-Control-Plugin 1.8.3 stopped working.
It worked prior to the update.

If I test the connection I got the error message:
[Fail] CSRF enabled -> Missing or bad crumb data
We already used an application token for authentification.

IntelliJ 2023.2 (Ultimate)
Jenkins 2.346.1

Message shown:
HTTP ERROR 403 No valid crumb was included in the request
URI:
/api/json
STATUS:
403
MESSAGE:
No valid crumb was included in the request
SERVLET:
Stapler
Powered by Jetty:// 9.4.45.v2022020

@ststoessel ststoessel changed the title Plugin can not conenct to Jenkins anmyore with: [Fail] CSRF enabled -> Missing or bad crumb data Plugin can not connect to Jenkins anmyore with: [Fail] CSRF enabled -> Missing or bad crumb data Aug 22, 2023
@MCMicS
Copy link
Owner

MCMicS commented Aug 22, 2023

Hi
i have to investigate this because in my test machines/setups it still works.
from which version do you have updated?

is the application token still valid or expired?

Can you test following from terminal please:

curl -u user:apiToken http://jenkins.server:8080/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

@ststoessel
Copy link
Author

ststoessel commented Aug 22, 2023

Thanks for you fast response. I got an authorization error and so I removed the old token and created a new one. It's working again. You are doing an incredible job with the plugin.

@MCMicS
Copy link
Owner

MCMicS commented Aug 22, 2023

Thanks a lot
nice to hear that it works now for you

@erickne
Copy link

erickne commented Aug 25, 2023

@MCMicS
Same problem here.

WebStorm 2023.1
Jenkins 2.417

  1. Created a new token
  2. Error 403 : missing crumbs
  3. Executed cURL command and got the response:
{"_class":"hudson.model.Hudson","nodeName":"","description":null,"primaryView":{"_class":"hudson.model.AllView","name":"all","url":"https://jenkins.*******/"},"url":"https://jenkins.******/"}

I tried server address with (and without) suffix:

image

image

@MCMicS
Copy link
Owner

MCMicS commented Aug 25, 2023

And used api token instead of password?
because password require crumb which ist not supported anymore

@ststoessel
Copy link
Author

ststoessel commented Aug 25, 2023

My solution was:

  1. Delete your old token from your account within Jenkins
  2. Create a new token
  3. Use this new token in the plugin

@MCMicS
Copy link
Owner

MCMicS commented Aug 25, 2023

Hi
can you repeat the cur command with -v and share the infos?

@erickne
Copy link

erickne commented Aug 25, 2023

And used api token instead of password? because password require crumb which ist not supported anymore

I tried with password and token.

My solution was:

  1. Delete your old token from your account within Jenkins
  2. Create a new token
  3. Use this new token in the plugin

I tried with new token :( .

Hi can you repeat the cur command with -v and share the infos?

Sure!


*   Trying x.x.x.x:443...
* TCP_NODELAY set
* Connected to jenkins.xxx.br (x.x.x.x) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=jenkins.xxxx.br
*  start date: Aug  7 20:55:12 2023 GMT
*  expire date: Nov  5 20:55:11 2023 GMT
*  subjectAltName: host "jenkins.xxxxxxxxxxxxxxx.br" matched cert's "jenkins.xxxxxxxxxxxxxx.br"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Server auth using Basic with user 'erick.engelhardt'
* Using Stream ID: 1 (easy handle 0x564faaed78d0)
> GET /api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D HTTP/2
> Host: jenkins.xxxxxxxxxxxxxxxxx.br
> authorization: Basic xxxxxxxxxxxxxxxxxxxTOKENxxxxxxxxxxxx
> user-agent: curl/7.68.0
> accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< server: nginx
< date: Fri, 25 Aug 2023 23:23:34 GMT
< content-type: application/json;charset=utf-8
< content-length: 222
< x-content-type-options: nosniff
< access-control-allow-credentials: true
< access-control-allow-origin: https://observability.browserstack.com
< access-control-allow-methods: POST, GET, OPTIONS, PUT
< access-control-allow-headers: *
< access-control-expose-headers: *
< access-control-max-age: 999
< x-jenkins: 2.417
< x-jenkins-session: 5deddbd9
< x-frame-options: deny
< x-powered-by: PleskLin
<
* Connection #0 to host jenkins.xxxxxxx.br left intact

Just to let you know, this instance is running in a Docker with Nginx reverse proxy.

@erickne
Copy link

erickne commented Aug 25, 2023

I used the same token in another plugin (Jenkins Pipeline Linter) and it's working.
image

@MCMicS
Copy link
Owner

MCMicS commented Aug 26, 2023

Is this aerver public visible and can you geant me access for test?
You can contact me privatly on gitter/matrix

Channel: https://matrix.to/#/#jenkins-control-plugin_community:gitter.im
Me:
https://matrix.to/#/@mcmics-58e400f2d73408ce4f561945:gitter.im

If not possible to grant access I can provide a version with extended logging

If you have any proxy configured in webstorm to use?

Ist this a new installation or was this working before and happens after an update?

Can you retry curl with Post please?
I will figure out if configuration/netwowork issue exists
curl -v -X Post -u user:apiToken http://jenkins.server:8080/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

@MCMicS MCMicS reopened this Aug 26, 2023
@erickne
Copy link

erickne commented Aug 27, 2023

Is this aerver public visible and can you geant me access for test? You can contact me privatly on gitter/matrix

Channel: https://matrix.to/#/#jenkins-control-plugin_community:gitter.im Me: https://matrix.to/#/@mcmics-58e400f2d73408ce4f561945:gitter.im

If not possible to grant access I can provide a version with extended logging

If you have any proxy configured in webstorm to use?

Ist this a new installation or was this working before and happens after an update?

Can you retry curl with Post please? I will figure out if configuration/netwowork issue exists curl -v -X Post -u user:apiToken http://jenkins.server:8080/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

It's working again! Please see my past message #512 (comment) .

@MCMicS
Copy link
Owner

MCMicS commented Aug 27, 2023

Ai thought you mean with the comment that your token worls in the linter plugin but not in jenkins control.

So its working for +u now? Then can this be closed?

@erickne
Copy link

erickne commented Aug 27, 2023 via email

@theandrewlane
Copy link

theandrewlane commented Mar 13, 2024

Hey @MCMicS!

I'm on 0.13.19-2023.2 and still facing this issue. My Jenkins is a CloudBees Ci Managed Controller, and the Jenkins Linter plugin is able to connect with the same username/token I'm trying here - I was actually configuring both plugins at the same time :)

My Jenkins configuration is a bit different - https://jenkins.server/api/json returns a 503 whereas https://jenkins.server/my-team-name/api/json returns the expected json.

The following curl command returns the expected result:

curl -v -X Post -u user:apiToken https://jenkins.server/my-team-name/api/json?tree=nodeName,url,description,primaryView%5Bname,url%5D

I've also tried these settings with the v0.13.17 (before the crumb config was removed) and got the same result.

Actual configuration params omitted
image

@MCMicS
Copy link
Owner

MCMicS commented Mar 14, 2024

hmm strange if you use api token the crumb shoulb be not needed. I can have look next week.
it is possible to grant access to check against?

@theandrewlane
Copy link

hmm strange if you use api token the crumb shoulb be not needed. I can have look next week. it is possible to grant access to check against?

Interesting... Welp I can assure you I'm using a Jenkins token - the same token I'm using for the Jenkins Linter plugin. I unfortunately cannot grant you access to my server, but I'm happy to help you debug!

@MCMicS
Copy link
Owner

MCMicS commented Mar 17, 2024

hmm I created special version with additinal logs a time ago (see #69 (comment)). may you can use this to get further informations or I add additional logs the days in a newer version

org.codinjutsu.tools.jenkins
#org.codinjutsu.tools.jenkins:trace

Plugin: https://github.com/MCMicS/jenkins-control-plugin/files/12533934/jenkins-control-plugin-0.13.19-eap3-2023.2-signed.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants