Skip to content

[JENKINS-37468] Only offer valid credentials in the credentials drop down#18

Merged
nemccarthy merged 1 commit intojenkinsci:masterfrom
stephenc:jenkins-37468
Sep 22, 2016
Merged

[JENKINS-37468] Only offer valid credentials in the credentials drop down#18
nemccarthy merged 1 commit intojenkinsci:masterfrom
stephenc:jenkins-37468

Conversation

@stephenc
Copy link
Member

See JENKINS-37468

I feel that the RFE is currently technically impossible as the REST API for query of the pull requests does not provide any support for SSH based authentication.

As such the RFE should probably be rejected.

Behind the RFE however, there is a valid bug. Namely that the drop down of credentials was including all Username based credentials (which would include SSH keys) yet only UsernamePassword credentials were being used.

This PR fixes the drop-down population to be restricted to Username Password credentials only.

Additionally this PR tidies up some of the usage of credentials (esp with respect to the interactions with the authorize-project plugin) and switches to the more modern APIs for populating drop-down boxes.

@reviewbybees @jenkinsci/code-reviewers

…down.

- There was a mismatch between the dropdown list and the credentials lookup. As only username password credentials are supported, only those should be listed
- Use Task.getDefaultAuthenticationOf(job) to ensure that the drop-down and lookup respects the authorize-project plugin
- Use CredentialsProvider.listCredentials based lookups for drop-down selection to ensure that dynamic credentials providers are not forced to retrieve the password where it is not required.
@ghost
Copy link

ghost commented Sep 21, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐝

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐝

import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
import hudson.Extension;
import hudson.model.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+💯

@@ -109,8 +115,12 @@ public String getcredentialsId() {

private StandardUsernamePasswordCredentials getCredentials() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Would be nice to have annotations if you change the code around

@stephenc
Copy link
Member Author

@reviewbybees done

@nemccarthy nemccarthy merged commit b27cc5d into jenkinsci:master Sep 22, 2016
@stephenc stephenc deleted the jenkins-37468 branch September 22, 2016 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants