diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/keys.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/keys.rb b/lib/api/keys.rb index d5280a0035d..8f2fd8cbae2 100644 --- a/lib/api/keys.rb +++ b/lib/api/keys.rb @@ -16,6 +16,23 @@ module API present key, with: Entities::SSHKeyWithUser, current_user: current_user end + + desc 'Get SSH Key information' do + success Entities::UserWithAdmin + end + params do + requires :fingerprint, type: String, desc: 'Search for a SSH fingerprint' + end + get do + authenticated_with_full_private_access! + + key = KeysFinder.new(current_user, params).execute + + not_found!('Key') unless key + present key, with: Entities::SSHKeyWithUser, current_user: current_user + rescue KeysFinder::InvalidFingerprint + render_api_error!('Failed to return the key', 400) + end end end end |