Commit 36efe0f5 authored by Saito's avatar Saito

Merge pull request #3634 from tsl0922/patch-grack-auth

fix http push 401 and 500 with some git clients
parents ae006dd9 f1c9b058
......@@ -76,13 +76,17 @@ module Grack
end
def validate_get_request
project.public || can?(user, :download_code, project)
validate_request(@request.params['service'])
end
def validate_post_request
if @request.path_info.end_with?('git-upload-pack')
validate_request(File.basename(@request.path))
end
def validate_request(service)
if service == 'git-upload-pack'
project.public || can?(user, :download_code, project)
elsif @request.path_info.end_with?('git-receive-pack')
elsif service == 'git-receive-pack'
action = if project.protected_branch?(current_ref)
:push_code_to_protected_branches
else
......@@ -107,7 +111,7 @@ module Grack
end
# Need to reset seek point
@request.body.rewind
/refs\/heads\/([\w\.-]+)/.match(input).to_a.last
/refs\/heads\/([\w\.-]+)/n.match(input.force_encoding('ascii-8bit')).to_a.last
end
def project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment