-
Notifications
You must be signed in to change notification settings - Fork 246
Add snapshot taker for special StandardUsernamePasswordCredentials
impls
#327
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&r 10000 dquo;, 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
Add snapshot taker for special StandardUsernamePasswordCredentials
impls
#327
Conversation
cc @jglick |
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.
Looks right.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 credentials-plugin/src/main/java/com/cloudbees/plugins/credentials/CredentialsProvider.java Lines 808 to 814 in be8bbce
|
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