summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorRonald Claveau <sousmangoosta@aliel.fr>2018-06-28 08:13:21 +0200
committerRonald Claveau <sousmangoosta@aliel.fr>2018-10-03 19:28:13 +0200
commit7d55c1353d6402f33a9fef734148fb776da076d3 (patch)
tree97042ecfabe94ffc49fc3f5b0e388b163bcf3adb /lib/api
parent227cc997fb107672e3293c56e0dcb1df72ad82d5 (diff)
downloadgitlab-ce-7d55c1353d6402f33a9fef734148fb776da076d3.tar.gz
List public ssh keys by id or username without authentication
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/users.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index ac09ca7f7b7..e96887948b1 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -254,7 +254,7 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the SSH keys of a specified user. Available only for admins.' do
+ desc 'Get the SSH keys of a specified user.' do
success Entities::SSHKey
end
params do
@@ -263,10 +263,8 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
get ':id/keys' do
- authenticated_as_admin!
-
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!('User') unless user && can?(current_user, :read_user, user)
present paginate(user.keys), with: Entities::SSHKey
end