diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-19 17:11:48 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-20 12:17:02 -0500 |
commit | a38603fcc2adbb0450cafa8edc9de43a0b64b231 (patch) | |
tree | a2f05f0d374713f152ea2881697d48adb4e42e3d /lib | |
parent | 95674fc14ea6b0f0c34376a699167952215f5702 (diff) | |
download | gitlab-ce-a38603fcc2adbb0450cafa8edc9de43a0b64b231.tar.gz |
Merge branch 'fix-users-deleting-public-deployment-keys' into 'security'
Fix users being able to delete instance public deployment keys
See merge request !2049
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/deploy_keys.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 825e05fbae3..53c5cd55f61 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -100,15 +100,19 @@ module API present key.deploy_key, with: Entities::SSHKey end - desc 'Delete existing deploy key of currently authenticated user' do + desc 'Delete deploy key for a project' do success Key end params do requires :key_id, type: Integer, desc: 'The ID of the deploy key' end delete ":id/#{path}/:key_id" do - key = user_project.deploy_keys.find(params[:key_id]) - key.destroy + key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id]) + if key + key.destroy + else + not_found!('Deploy Key') + end end end end |