summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
authorPablo Carranza <pcarranza@gmail.com>2016-03-01 17:53:01 +0000
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2018-01-08 20:34:16 +0000
commitac86b2043dea8f15cb0670db98c2bf21e1843d4b (patch)
tree3979de272a8974697a7d051462ef0a8ba94704d0 /lib/api/internal.rb
parentae46ceaab097923b46099a87d8ca63443aa85248 (diff)
downloadgitlab-ce-ac86b2043dea8f15cb0670db98c2bf21e1843d4b.tar.gz
Backport authorized_keys branch 'find-key-by-fingerprint'
Add find key by base64 key or fingerprint to the internal API See merge request !250 Squashed changes: Add unique index to fingerprint Add new index to schema Add internal api to get ssh key by fingerprint Change API endpoint to authorized_keys Add InsecureKeyFingerprint that calculates the fingerprint without shelling out Add require for gitlab key fingerprint Remove uniqueness of fingerprint index Remove unique option from migration Fix spec style in fingerprint test Fix rubocop complain Extract insecure key fingerprint to separate file Change migration to support building index concurrently Remove those hideous tabs
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 79b302aae70..8bf53939751 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -82,6 +82,18 @@ module API
end
#
+ # Get a ssh key using the fingerprint
+ #
+ get "/authorized_keys" do
+ fingerprint = params.fetch(:fingerprint) do
+ Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
+ end
+ key = Key.find_by(fingerprint: fingerprint)
+ not_found!("Key") if key.nil?
+ present key, with: Entities::SSHKey
+ end
+
+ #
# Discover user by ssh key or user id
#
get "/discover" do