Commit 935b6ae6534e77f2b9e84bcb686aeeda88089122
1 parent
6f7ccea6
Exists in
master
and in
4 other branches
Internal API
Showing
2 changed files
with
25 additions
and
0 deletions
Show diff stats
lib/api.rb
... | ... | @@ -0,0 +1,24 @@ |
1 | +module Gitlab | |
2 | + # Access API | |
3 | + class Internal < Grape::API | |
4 | + | |
5 | + get "/allowed" do | |
6 | + user = User.find_by_username(params[:username]) | |
7 | + project = Project.find_with_namespace(params[:project]) | |
8 | + action = case params[:action] | |
9 | + when 'git-upload-pack' | |
10 | + then :download_code | |
11 | + when 'git-receive-pack' | |
12 | + then | |
13 | + if project.protected_branch?(params[:ref]) | |
14 | + :push_code_to_protected_branches | |
15 | + else | |
16 | + :push_code | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + user.can?(action, project) | |
21 | + end | |
22 | + end | |
23 | +end | |
24 | + | ... | ... |