summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 19:44:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-30 19:44:55 +0000
commitf526ce392a317feb5a125bb16adb2629a487ce70 (patch)
tree8ab2b3458181a6cce84b401ce7dc9326fc0f5384 /app/services
parentf19a0fa10a0024fab5ef3c556612944f2a62c298 (diff)
downloadgitlab-ce-f526ce392a317feb5a125bb16adb2629a487ce70.tar.gz
Add latest changes from gitlab-org/security/gitlab@14-2-stable-ee
Diffstat (limited to 'app/services')
-rw-r--r--app/services/jira_connect_subscriptions/create_service.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/services/jira_connect_subscriptions/create_service.rb b/app/services/jira_connect_subscriptions/create_service.rb
index 38e5fe7e690..2f31a3c8d4e 100644
--- a/app/services/jira_connect_subscriptions/create_service.rb
+++ b/app/services/jira_connect_subscriptions/create_service.rb
@@ -5,8 +5,11 @@ module JiraConnectSubscriptions
include Gitlab::Utils::StrongMemoize
MERGE_REQUEST_SYNC_BATCH_SIZE = 20
MERGE_REQUEST_SYNC_BATCH_DELAY = 1.minute.freeze
+ NOT_SITE_ADMIN = 'The Jira user is not a site administrator.'
def execute
+ return error(NOT_SITE_ADMIN, 403) unless can_administer_jira?
+
unless namespace && can?(current_user, :create_jira_connect_subscription, namespace)
return error('Invalid namespace. Please make sure you have sufficient permissions', 401)
end
@@ -16,6 +19,10 @@ module JiraConnectSubscriptions
private
+ def can_administer_jira?
+ @params[:jira_user]&.site_admin?
+ end
+
def create_subscription
subscription = JiraConnectSubscription.new(installation: jira_connect_installation, namespace: namespace)