-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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-38048] Permit credentialsId dropdowns to be used from a global configuration screen #437
Changes from 1 commit
b52b095
62d404f
bf0465f
1c20b76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
import com.cloudbees.plugins.credentials.common.StandardCredentials; | ||
import com.cloudbees.plugins.credentials.common.StandardListBoxModel; | ||
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; | ||
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; | ||
import hudson.EnvVars; | ||
import hudson.Extension; | ||
import hudson.Util; | ||
|
@@ -36,6 +35,7 @@ | |
|
||
import static hudson.Util.fixEmpty; | ||
import static hudson.Util.fixEmptyAndTrim; | ||
import javax.annotation.CheckForNull; | ||
|
||
@ExportedBean | ||
public class UserRemoteConfig extends AbstractDescribableImpl<UserRemoteConfig> implements Serializable { | ||
|
@@ -85,7 +85,8 @@ public static class DescriptorImpl extends Descriptor<UserRemoteConfig> { | |
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project, | ||
@QueryParameter String url, | ||
@QueryParameter String credentialsId) { | ||
if (project == null || !project.hasPermission(Item.EXTENDED_READ)) { | ||
if (project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) || | ||
project != null && !project.hasPermission(Item.EXTENDED_READ)) { | ||
return new StandardListBoxModel().includeCurrentValue(credentialsId); | ||
} | ||
return new StandardListBoxModel() | ||
|
@@ -104,7 +105,8 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project, | |
public FormValidation doCheckCredentialsId(@AncestorInPath Item project, | ||
@QueryParameter String url, | ||
@QueryParameter String value) { | ||
if (project == null || !project.hasPermission(Item.EXTENDED_READ)) { | ||
if (project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) || | ||
project != null && !project.hasPermission(Item.EXTENDED_READ)) { | ||
return FormValidation.ok(); | ||
} | ||
|
||
|
@@ -149,7 +151,8 @@ public FormValidation doCheckUrl(@AncestorInPath Item item, | |
|
||
// Normally this permission is hidden and implied by Item.CONFIGURE, so from a view-only form you will not be able to use this check. | ||
// (TODO under certain circumstances being granted only USE_OWN might suffice, though this presumes a fix of JENKINS-31870.) | ||
if (item == null || !item.hasPermission(CredentialsProvider.USE_ITEM)) { | ||
if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) || | ||
item != null && !item.hasPermission(CredentialsProvider.USE_ITEM)) { | ||
return FormValidation.ok(); | ||
} | ||
|
||
|
@@ -185,7 +188,7 @@ public FormValidation doCheckUrl(@AncestorInPath Item item, | |
return FormValidation.ok(); | ||
} | ||
|
||
private static StandardCredentials lookupCredentials(Item project, String credentialId, String uri) { | ||
private static StandardCredentials lookupCredentials(@CheckForNull Item project, String credentialId, String uri) { | ||
return (credentialId == null) ? null : CredentialsMatchers.firstOrNull( | ||
CredentialsProvider.lookupCredentials(StandardCredentials.class, project, ACL.SYSTEM, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather be explicit in plugins about what to fall back to if the project is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
GitURIRequirementsBuilder.fromUri(uri).build()), | ||
|
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 the diff hunk currently covered by the functional test—the one most important for the reported bug.