Skip to content
Snippets Groups Projects
Commit 9397ce91 authored by Patricio Cano's avatar Patricio Cano
Browse files

Correct access control flow for Git HTTP requests.

parent da15471b
No related branches found
No related tags found
1 merge request!4696Add setting that allows admins to choose which Git access protocols are enabled.
Loading
@@ -174,14 +174,20 @@ class Projects::GitHttpController < Projects::ApplicationController
Loading
@@ -174,14 +174,20 @@ class Projects::GitHttpController < Projects::ApplicationController
end end
end end
   
def access
return @access if defined?(@access)
@access = Gitlab::GitAccess.new(user, project, 'http')
end
def download_access def download_access
return @download_access if defined?(@download_access) return @download_access if defined?(@download_access)
   
@download_access = Gitlab::GitAccess.new(user, project, 'http').check('git-upload-pack') @download_access = access.check('git-upload-pack')
end end
   
def http_blocked? def http_blocked?
download_access.protocol_allowed? !access.protocol_allowed?
end end
   
def receive_pack_allowed? def receive_pack_allowed?
Loading
Loading
Loading
@@ -169,6 +169,10 @@ module Gitlab
Loading
@@ -169,6 +169,10 @@ module Gitlab
Gitlab::ForcePushCheck.force_push?(project, oldrev, newrev) Gitlab::ForcePushCheck.force_push?(project, oldrev, newrev)
end end
   
def protocol_allowed?
Gitlab::ProtocolAccess.allowed?(protocol)
end
private private
   
def protected_branch_action(oldrev, newrev, branch_name) def protected_branch_action(oldrev, newrev, branch_name)
Loading
@@ -193,10 +197,6 @@ module Gitlab
Loading
@@ -193,10 +197,6 @@ module Gitlab
Gitlab::UserAccess.allowed?(user) Gitlab::UserAccess.allowed?(user)
end end
   
def protocol_allowed?
Gitlab::ProtocolAccess.allowed?(protocol)
end
def branch_name(ref) def branch_name(ref)
ref = ref.to_s ref = ref.to_s
if Gitlab::Git.branch_ref?(ref) if Gitlab::Git.branch_ref?(ref)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment