diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 19:53:43 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-04 19:53:43 +0400 |
commit | 935b6ae6534e77f2b9e84bcb686aeeda88089122 (patch) | |
tree | 036935d9465495800cc76e846e76844aacb2a39b /lib | |
parent | 6f7ccea6686d4cc6c6241bc4289c13ff04cc8557 (diff) |
Internal API
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api.rb | 1 | ||||
-rw-r--r-- | lib/api/internal.rb | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/api.rb b/lib/api.rb index f58b82ff98e..3ee56a7f79e 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -19,5 +19,6 @@ module Gitlab mount Session mount MergeRequests mount Notes + mount Internal end end 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 + |