-
Notifications
You must be signed in to change notification settings - Fork 354
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
[JENKINS-74970] Log user name and repository if Bitbucket Server forbids posting a build status #965
base: master
Are you sure you want to change the base?
Conversation
Not yet happy with:
For the permission levels, I'm thinking the |
The username is already logged because recently I have add all headers to the error message. This helped in JENKINS-75106
I can not keep track of each permission required for each API, and move forward useless parameter to methods only for logs. |
You mean response headers, right? Not request headers, which typically include secrets. |
This gets tricky in the getMirroredRepository method, where the request may require authentication, but the credentials are already included in the
According to #829 (comment), the query component of the request URL can contain an authentication token. That should not be written to a log that users can read. At this point, I'm thinking of adding to |
Yes, request contains sensible information and username could be marked as "Treat username as secret" in credentials. |
Enrich the URLUtils#removeAuthority to remove also the jwt queryParam so it can be used for log |
You can improve the user documentation for that use case, I want share client code as much code as possible and not provide callback for which the called have to handle response and depends on http client code. See also pr #963 in case |
Does Atlassian document the name of the query parameter? |
No they speak about authenticated links |
* @param response The HTTP response from Bitbucket. | ||
* @return Advice to the user on why the request failed, or {@code null}. | ||
*/ | ||
@CheckForNull String getAdvice(HttpResponse response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is HttpResponse rather than CloseableHttpResponse because the method should not close the response.
3ecfe65
to
a5a8dcb
Compare
If this plugin posts a build status to Bitbucket Server or Data Center, but Bitbucket responds with HTTP status 401 (Unauthorized) or 403 (Forbidden), then log extra information to help users grant Jenkins the required permission on the repository: * The permission that is needed: REPO_READ. * The Bitbucket user name. Currently, this comes from the "X-AUSERNAME" response header field. * The repository to which the request was sent. * The project or user that owns the repository. Because BitbucketServerAPIClient does not have direct access to a TaskListener, it adds this information to the message of the BitbucketRequestException, and the caller then logs it from there. The behaviour on Bitbucket Cloud is unchanged.
a5a8dcb
to
26ef0dd
Compare
If Bitbucket Server responds with HTTP status 401 (Unauthorized) or 403 (Forbidden) when this plugin posts a build status, and the HTTP response includes an "X-AUSERNAME" header field that shows Bitbucket Server authenticated the user, then add more information in the message of the BitbucketRequestException:
The behaviour is unchanged on Bitbucket Cloud, and on Bitbucket Server for operations other than posting a build status.
Your checklist for this pull request