Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb29
1 files changed, 4 insertions, 25 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 38430aac455..aadcbe38b15 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -504,12 +504,12 @@ module API
def render_validation_error!(model, status = 400)
if model.errors.any?
- render_api_error!(model_error_messages(model) || '400 Bad Request', status)
+ render_api_error!(model_errors(model).messages || '400 Bad Request', status)
end
end
- def model_error_messages(model)
- model.errors.messages
+ def model_errors(model)
+ model.errors
end
def render_api_error_with_reason!(status, message, reason)
@@ -608,7 +608,7 @@ module API
if file.file_storage?
present_disk_file!(file.path, file.filename)
elsif supports_direct_download && file.class.direct_download_enabled?
- return redirect(signed_head_url(file)) if head_request_on_aws_file?(file)
+ return redirect(ObjectStorage::S3.signed_head_url(file)) if request.head? && file.fog_credentials[:provider] == 'AWS'
redirect(cdn_fronted_url(file))
else
@@ -691,15 +691,7 @@ module API
{}
end
- def validate_anonymous_search_access!
- return if current_user.present? || Feature.disabled?(:disable_anonymous_search, type: :ops)
-
- unprocessable_entity!('User must be authenticated to use search')
- end
-
def validate_search_rate_limit!
- return unless Feature.enabled?(:rate_limit_issuable_searches)
-
if current_user
check_rate_limit!(:search_rate_limit, scope: [current_user])
else
@@ -709,19 +701,6 @@ module API
private
- def head_request_on_aws_file?(file)
- request.head? && file.fog_credentials[:provider] == 'AWS'
- end
-
- def signed_head_url(file)
- fog_storage = ::Fog::Storage.new(file.fog_credentials)
- fog_dir = fog_storage.directories.new(key: file.fog_directory)
- fog_file = fog_dir.files.new(key: file.path)
- expire_at = ::Fog::Time.now + file.fog_authenticated_url_expiration
-
- fog_file.collection.head_url(fog_file.key, expire_at)
- end
-
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def initial_current_user
return @initial_current_user if defined?(@initial_current_user)