diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 17:53:43 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 17:53:43 +0200 |
commit | 935b6ae6534e77f2b9e84bcb686aeeda88089122 (patch) | |
tree | 036935d9465495800cc76e846e76844aacb2a39b /lib/api | |
parent | 6f7ccea6686d4cc6c6241bc4289c13ff04cc8557 (diff) | |
download | gitlab-ce-935b6ae6534e77f2b9e84bcb686aeeda88089122.tar.gz |
Internal API
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/internal.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb new file mode 100644 index 00000000000..c12605841ab --- /dev/null +++ b/lib/api/internal.rb @@ -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 + |