Add snapshot taker for special StandardUsernamePasswordCredentials impls#327
Conversation
|
cc @jglick |
jglick
left a comment
There was a problem hiding this comment.
Ah no, it fails to copy the usernameSecret field.
I would suggest just returning the argument unchanged if it happens to be a UsernamePasswordCredentialsImpl.
StandardUsernamePasswordCredentials impls
| if (credentials instanceof UsernamePasswordCredentialsImpl) { | ||
| return credentials; | ||
| } | ||
| return new UsernamePasswordCredentialsImpl(credentials.getScope(), credentials.getId(), credentials.getDescription(), credentials.getUsername(), Secret.toString(credentials.getPassword())); |
There was a problem hiding this comment.
| return new UsernamePasswordCredentialsImpl(credentials.getScope(), credentials.getId(), credentials.getDescription(), credentials.getUsername(), Secret.toString(credentials.getPassword())); | |
| UsernamePasswordCredentialsImpl snapshot = new UsernamePasswordCredentialsImpl(credentials.getScope(), credentials.getId(), credentials.getDescription(), credentials.getUsername(), Secret.toString(credentials.getPassword())); | |
| snapshot.setUsernameSecret(credentials.isUsernameSecret()); | |
| return snapshot; |
just in case other impls now implement this parameter as well.
Main problem addressed. A minor suggestion remains.
|
We have a confirmation of this change working with vault (jenkinsci/hashicorp-vault-plugin#201 (comment)), from commit |
|
noting this seemingly breaks |
|
@jtnord by “breaks” do you mean specifically the token refresh https://github.com/jenkinsci/github-branch-source-plugin/blob/7618247e672d2008fa8dc006ee8e87f4e64ab2c4/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java#L497? If so, I guess the correct fix is to replace |
exactly that.
I'm working on it, there be some dragons I am trying to understand first. |
|
See discussion in jenkinsci/github-branch-source-plugin#334. |
This adds a snapshot taker for StandardUsernamePasswordCredentials. This is needed to fix an issue in hashicorp-vault plugin which currently prevents ssh keys being sent to agents which is being developed in jenkinsci/hashicorp-vault-plugin#218