diff options
author | Robert Speicher <robert@gitlab.com> | 2017-01-19 20:11:48 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-20 20:16:45 +0300 |
commit | e579e7109d9a51dc4c8f4d000a69d81c9103cd96 (patch) | |
tree | c45804d02d66b74ca3fdfe42e1c3bb1f67699d4b | |
parent | a0f4d3820fa8d53ada48f67c39d64b4dc4b6a314 (diff) |
Merge branch 'fix-users-deleting-public-deployment-keys' into 'security'
Fix users being able to delete instance public deployment keys
See merge request !2049
-rw-r--r-- | changelogs/unreleased/fix-users-deleting-public-deployment-keys.yml | 4 | ||||
-rw-r--r-- | lib/api/deploy_keys.rb | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/changelogs/unreleased/fix-users-deleting-public-deployment-keys.yml b/changelogs/unreleased/fix-users-deleting-public-deployment-keys.yml new file mode 100644 index 00000000000..c9edd1de86c --- /dev/null +++ b/changelogs/unreleased/fix-users-deleting-public-deployment-keys.yml @@ -0,0 +1,4 @@ +--- +title: Prevent users from deleting system deploy keys via the project deploy key API +merge_request: +author: diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 85360730841..f6cb17bafd8 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -105,15 +105,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 |