From 92537803802db9184b3b7f2eb10cad4a2a11a112 Mon Sep 17 00:00:00 2001 From: Stonewall Jackson Date: Wed, 6 Mar 2024 16:31:39 -0500 Subject: [PATCH] Fix 'missing the Job/Configure permssion' error on Branch Sources page When this plugin is used in combination with the "Role-Based Authorization Strategy", the "Branch Sources" job configation page throws the following error: $USER is missing the Job/Configure permission This error is shown even when the user has full Admin rights on the Jenkins instance. I'm not sure that this fix is 100% correct, but it does resolve the problem. I noticed that the following PR in a similar project fixed a similar issue (JENKINS-60116) by checking for the `EXTENDED_READ` permission: https://github.com/jenkinsci/atlassian-bitbucket-server-integration-plugin/pull/165 So I blindly did the same thing. Would appreciate someone checking my work! --- .../jenkins/plugins/bitbucket/BitbucketSCMNavigator.java | 2 +- .../jenkins/plugins/bitbucket/BitbucketSCMSource.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java index a542fcb83..744999e36 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java @@ -639,7 +639,7 @@ public boolean isServerUrlSelectable() { @SuppressWarnings("unused") // used By stapler public ListBoxModel doFillServerUrlItems(@AncestorInPath SCMSourceOwner context) { AccessControlled contextToCheck = context == null ? Jenkins.get() : context; - if (!contextToCheck.hasPermission(Item.CONFIGURE)) { + if (!contextToCheck.hasAnyPermission(Item.CONFIGURE, Item.EXTENDED_READ)) { return new ListBoxModel(); } return BitbucketEndpointConfiguration.get().getEndpointItems(); diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java index 232292a2b..c821ad73e 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java @@ -1346,7 +1346,7 @@ public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath SCMSour @SuppressWarnings("unused") // used By stapler public static FormValidation doCheckServerUrl(@AncestorInPath SCMSourceOwner context, @QueryParameter String value) { AccessControlled contextToCheck = context == null ? Jenkins.get() : context; - contextToCheck.checkPermission(Item.CONFIGURE); + contextToCheck.checkAnyPermission(Item.CONFIGURE, Item.EXTENDED_READ); if (BitbucketEndpointConfiguration.get().findEndpoint(value) == null) { return FormValidation.error("Unregistered Server: " + value); } @@ -1373,7 +1373,7 @@ public boolean isServerUrlSelectable() { @SuppressWarnings("unused") // used By stapler public ListBoxModel doFillServerUrlItems(@AncestorInPath SCMSourceOwner context) { AccessControlled contextToCheck = context == null ? Jenkins.get() : context; - if (!contextToCheck.hasPermission(Item.CONFIGURE)) { + if (!contextToCheck.hasAnyPermission(Item.CONFIGURE, Item.EXTENDED_READ)) { return new ListBoxModel(); } return BitbucketEndpointConfiguration.get().getEndpointItems();