Internal API
This commit is contained in:
parent
6f7ccea668
commit
935b6ae653
2 changed files with 25 additions and 0 deletions
|
@ -19,5 +19,6 @@ module Gitlab
|
|||
mount Session
|
||||
mount MergeRequests
|
||||
mount Notes
|
||||
mount Internal
|
||||
end
|
||||
end
|
||||
|
|
24
lib/api/internal.rb
Normal file
24
lib/api/internal.rb
Normal 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
|
||||
|
Loading…
Reference in a new issue