summaryrefslogtreecommitdiff
path: root/lib/api/internal
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-20 11:10:13 +0000
commit0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch)
tree7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /lib/api/internal
parent72123183a20411a36d607d70b12d57c484394c8e (diff)
downloadgitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'lib/api/internal')
-rw-r--r--lib/api/internal/base.rb12
-rw-r--r--lib/api/internal/mail_room.rb6
-rw-r--r--lib/api/internal/workhorse.rb37
3 files changed, 54 insertions, 1 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb
index b53f855c3a2..3edd38a0108 100644
--- a/lib/api/internal/base.rb
+++ b/lib/api/internal/base.rb
@@ -164,6 +164,18 @@ module API
check_allowed(params)
end
+ post '/error_tracking_allowed', feature_category: :error_tracking do
+ public_key = params[:public_key]
+ project_id = params[:project_id]
+
+ unprocessable_entity! if public_key.blank? || project_id.blank?
+
+ enabled = ::ErrorTracking::ClientKey.enabled_key_for(project_id, public_key).exists?
+
+ status 200
+ { enabled: enabled }
+ end
+
post "/lfs_authenticate", feature_category: :source_code_management, urgency: :high do
not_found! unless container&.lfs_enabled?
diff --git a/lib/api/internal/mail_room.rb b/lib/api/internal/mail_room.rb
index 6e24cf6e7c5..1e5e8c4c4e2 100644
--- a/lib/api/internal/mail_room.rb
+++ b/lib/api/internal/mail_room.rb
@@ -12,6 +12,10 @@ module API
class MailRoom < ::API::Base
feature_category :service_desk
+ format :json
+ content_type :txt, 'text/plain'
+ default_format :txt
+
before do
authenticate_gitlab_mailroom_request!
end
@@ -30,7 +34,7 @@ module API
end
post "/*mailbox_type" do
worker = Gitlab::MailRoom.worker_for(params[:mailbox_type])
- raw = request.body.read
+ raw = Gitlab::EncodingHelper.encode_utf8(request.body.read)
begin
worker.perform_async(raw)
rescue Gitlab::SidekiqMiddleware::SizeLimiter::ExceedLimitError
diff --git a/lib/api/internal/workhorse.rb b/lib/api/internal/workhorse.rb
new file mode 100644
index 00000000000..910cf52bc3b
--- /dev/null
+++ b/lib/api/internal/workhorse.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module API
+ module Internal
+ class Workhorse < ::API::Base
+ feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
+
+ before do
+ verify_workhorse_api!
+ content_type Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
+ end
+
+ helpers do
+ def request_authenticated?
+ authenticator = Gitlab::Auth::RequestAuthenticator.new(request)
+ return true if authenticator.find_authenticated_requester([:api])
+
+ # Look up user from warden, ignoring the absence of a CSRF token. For
+ # web users the CSRF token can be in the POST form data but Workhorse
+ # does not propagate the form data to us.
+ !!request.env['warden']&.authenticate
+ end
+ end
+
+ namespace 'internal' do
+ namespace 'workhorse' do
+ post 'authorize_upload' do
+ unauthorized! unless request_authenticated?
+
+ status 200
+ { TempPath: File.join(::Gitlab.config.uploads.storage_path, 'uploads/tmp') }
+ end
+ end
+ end
+ end
+ end
+end