summaryrefslogtreecommitdiff
path: root/lib/api/internal/base.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 18:25:58 +0000
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /lib/api/internal/base.rb
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
downloadgitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/api/internal/base.rb')
-rw-r--r--lib/api/internal/base.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb
index e16149185c9..ee0ddccc8d4 100644
--- a/lib/api/internal/base.rb
+++ b/lib/api/internal/base.rb
@@ -10,8 +10,6 @@ module API
api_endpoint = env['api.endpoint']
feature_category = api_endpoint.options[:for].try(:feature_category_for_app, api_endpoint).to_s
- header[Gitlab::Metrics::RequestsRackMiddleware::FEATURE_CATEGORY_HEADER] = feature_category
-
Gitlab::ApplicationContext.push(
user: -> { actor&.user },
project: -> { project },
@@ -169,18 +167,15 @@ module API
end
#
- # Get a ssh key using the fingerprint
+ # Check whether an SSH key is known to GitLab
#
- # rubocop: disable CodeReuse/ActiveRecord
get '/authorized_keys', feature_category: :source_code_management do
- fingerprint = params.fetch(:fingerprint) do
- Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
- end
- key = Key.find_by(fingerprint: fingerprint)
+ fingerprint = Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
+
+ key = Key.find_by_fingerprint(fingerprint)
not_found!('Key') if key.nil?
present key, with: Entities::SSHKey
end
- # rubocop: enable CodeReuse/ActiveRecord
#
# Discover user by ssh key, user id or username