cliffano / nestor

Jenkins CLI and node.js client
http://blog.cliffano.com/tag/nestor/
MIT License
182 stars 27 forks source link

Getting prompted for Password without Username #40

Closed ghost closed 7 years ago

ghost commented 8 years ago

When I enter the following command

JENKINS_URL=https://host nestor --interactive build build-name

I get prompted for my password (but not my username):

prompt: Password:

Furthermore, when I enter my password, I am given the following error:

  Authentication failed - incorrect username and/or password in Jenkins URL
ghost commented 8 years ago

image

cliffano commented 7 years ago

@paolo-tanium What Jenkins version are you using? Does it have CSRF enabled?

One possible cause to this problem is that Jenkins will return 403 with a message about invalid breadcrumb when CSRF is enabled. I'll need to add support for retrieving crumb value, and then hook it up to build job.

For future reference, here's a sample message body: '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\n<title>Error 403 No valid crumb was included in the request</title>\n</head>\n<body><h2>HTTP ERROR 403</h2>\n<p>Problem accessing /job/temp/build. Reason:\n<pre> No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>\n\n</body>\n</html>\n'

ghost commented 7 years ago

Version 2.19.1. Unfortunately I don't have admin access so I don't know if it is CSRF enabled. I'll try asking our admin tomorrow.

cliffano commented 7 years ago

@paolo-tanium Thanks that information would be helpful.

Another question, do you get that error only when you kick of a build? What about when you run dashboard command with interactive flag?

cliffano commented 7 years ago

@paolo-tanium I just released Nestor v1.0.1 , could you please try it?

New installations of Jenkins 2.x onward has CSRF protection enabled by default. This new version of Nestor always adds Jenkins crumb request header to solve the 403 invalid crumb problem.

cliffano commented 7 years ago

@paolo-tanium Closing this issue for now. Please try Nestor v1.0.1 or newer for your issue. Please feel free to re-open if you're still experiencing the problem.