-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[inputs.jenkins] It seems to use the authority of Anonymous Users. #5181
Comments
Can you verify the credentials are correct? In my tests, I saw the same header being passed by both curl and telegraf. Running telegraf with the following config[[inputs.jenkins]]
url = "http://localhost:8080"
username = "user"
password = "pass"
response_timeout = "10s" Server recieves the following request:
Running curl
|
Yes. I can verify. Curl test result$ curl -I -u user:token http://localhost:8080/computer/api/json
HTTP/1.1 200 OK
Date: Sat, 22 Dec 2018 15:09:40 GMT
X-Content-Type-Options: nosniff
X-Jenkins: 2.150.1
X-Jenkins-Session: 0b0d5ca4
Content-Type: application/json;charset=utf-8
Content-Length: 1499
Server: Jetty(9.4.z-SNAPSHOT) Additional info:
|
I just ran a netcat listener on port 8080 to see what headers both curl and telegraf was using. |
I'm sorry for the late reply. Ncat test resultsTelegraf: GET /computer/api/json HTTP/1.1
Host: localhost:8080
User-Agent: Go-http-client/1.1
Accept: application/json
Authorization: Basic TFAxMjA5Nzox
Accept-Encoding: gzip Curl: GET /computer/api/json HTTP/1.1
Authorization: Basic TFAxMjA5Nzox
User-Agent: curl/7.29.0
Host: localhost:8080
Accept: */* |
It looks like the tokens are the same, is that error log coming from another config stanza without username/password set perhaps? |
The '$remote_user' value of request that Telegraf sent is blank. Nginx access logcurl
Telegraf:jenkins
Nginx access log format
The request that Telegraf sent is a correct request? |
Are you using a config directory or another jenkins input defined in your current config file? As far as I can tell, telegraf is sending the correct request as I have been unable to reproduce this, which leads me to believe it's a config issue. I do want to know for sure though before dismissing this as such |
Was there ever a solution to this? I'm experiencing the same problem: hitting The HTTP 403 returned by Jenkins seems to indicate that the authentication is successful (it would otherwise return HTTP 401 on invalid credentials). Granting "Anonymous Users" full read permissions allows the plugin to produce metrics correctly. |
I couldn't find a solution. Overall - Read |
I've identified a workaround. In configuration, using
Instead of
works. ¯\_(ツ)_/¯ I've been digging through the source code of both the plugin and Jenkins itself. I suspect there's a bug in the way the plugin switches between using session cookies and HTTP basic auth credentials through multiple requests. My guess is that the initial request to Anyway, this workaround is acceptable to me so I'm not particularly incentivized to continue digging for a root cause. |
I can reproduce this with the debian package from http://pkg.jenkins.io/debian-stable. The initial connection succeeds because it includes the basic auth header but subsequent queries with only the JSESSIONID cookie are not enough to authenticate. @kelwang You mentioned that this method was used "to prevent github auth rate limit", would it be a problem if we always sent basic auth along with the previously set JSESSIONID? This seems to work without cycling the session using curl:
|
@danielnelson should be fine, I also feel it might be safer to make it as a configurable option. |
I created Token and used.
However, it seems to use 'Anonymous Users' authority.
Relevant telegraf.conf:
System info:
[Include Telegraf version, operating system name, and other relevant details]
Steps to reproduce:
Expected behavior:
Have to get authority of the user.
Actual behavior:
It seems to use the authority of Anonymous Users.
Additional info:
[Include gist of relevant config, logs, etc.]
The text was updated successfully, but these errors were encountered: