summaryrefslogtreecommitdiff
path: root/lib/api/lint.rb
diff options
context:
space:
mode:
authorGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2021-12-06 23:11:24 +0000
committerGitLab Release Tools Bot <delivery-team+release-tools@gitlab.com>2021-12-06 23:11:24 +0000
commit859d87224c756ee7c492f8cd03796c0c1f39b5b1 (patch)
tree33533cede7d7baa81bfb3dd7655d5d98bc59e125 /lib/api/lint.rb
parentb46b1a8bf2602a42329c0f6d0a7c40d74deb4e34 (diff)
parent314aa87d52b166ef0de60736f28fec1b5549c7eb (diff)
downloadgitlab-ce-14-3-stable.tar.gz
Merge remote-tracking branch 'dev/14-3-stable' into 14-3-stable14-3-stable
Diffstat (limited to 'lib/api/lint.rb')
-rw-r--r--lib/api/lint.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/lint.rb b/lib/api/lint.rb
index fa871b4bc57..d7d1f52c02e 100644
--- a/lib/api/lint.rb
+++ b/lib/api/lint.rb
@@ -4,6 +4,16 @@ module API
class Lint < ::API::Base
feature_category :pipeline_authoring
+ helpers do
+ def can_lint_ci?
+ signup_unrestricted = Gitlab::CurrentSettings.signup_enabled? && !Gitlab::CurrentSettings.signup_limited?
+ internal_user = current_user.present? && !current_user.external?
+ is_developer = current_user.present? && current_user.projects.any? { |p| p.team.member?(current_user, Gitlab::Access::DEVELOPER) }
+
+ signup_unrestricted || internal_user || is_developer
+ end
+ end
+
namespace :ci do
desc 'Validation of .gitlab-ci.yml content'
params do
@@ -11,7 +21,7 @@ module API
optional :include_merged_yaml, type: Boolean, desc: 'Whether or not to include merged CI config yaml in the response'
end
post '/lint' do
- unauthorized! if (Gitlab::CurrentSettings.signup_disabled? || Gitlab::CurrentSettings.signup_limited?) && current_user.nil?
+ unauthorized! unless can_lint_ci?
result = Gitlab::Ci::Lint.new(project: nil, current_user: current_user)
.validate(params[:content], dry_run: false)