Internal API

This commit is contained in:
Dmitriy Zaporozhets 2013-02-04 17:53:43 +02:00
parent 6f7ccea668
commit 935b6ae653
2 changed files with 25 additions and 0 deletions

View file

@ -19,5 +19,6 @@ module Gitlab
mount Session
mount MergeRequests
mount Notes
mount Internal
end
end

24
lib/api/internal.rb Normal file
View file

@ -0,0 +1,24 @@
module Gitlab
# Access API
class Internal < Grape::API
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
end
end
user.can?(action, project)
end
end
end