diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-05 12:47:50 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-05 12:47:50 +0200 |
commit | 70e3bffd95eb5736dd108e0836abaa85a2f1c742 (patch) | |
tree | effcda0ec2a1b5e8437740cfe848226abd3200a2 /lib/api/internal.rb | |
parent | 39e37677f291c344e25583916a1811a052e38db6 (diff) | |
download | gitlab-ce-70e3bffd95eb5736dd108e0836abaa85a2f1c742.tar.gz |
Fixed: post-receive, project remove, tests
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r-- | lib/api/internal.rb | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb index c12605841ab..576b64d04c3 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,23 +1,37 @@ module Gitlab - # Access API + # Internal access API class Internal < Grape::API + namespace 'internal' do + # + # Check if ssh key has access to project code + # + get "/allowed" do + key = Key.find(params[:key_id]) + user = key.user - get "/allowed" do - user = User.find_by_username(params[:username]) - project = Project.find_with_namespace(params[:project]) - action = case params[:action] - when 'git-upload-pack' - then :download_code - when 'git-receive-pack' - then - if project.protected_branch?(params[:ref]) - :push_code_to_protected_branches - else - :push_code + project = Project.find_with_namespace(params[:project]) + action = case params[:action] + when 'git-upload-pack' + then :download_code + when 'git-receive-pack' + then + if project.protected_branch?(params[:ref]) + :push_code_to_protected_branches + else + :push_code + end end - end - user.can?(action, project) + user.can?(action, project) + end + + # + # Discover user by ssh key + # + get "/discover" do + key = Key.find(params[:key_id]) + present key.user, with: Entities::User + end end end end |