Commit ef61d1f20004f20ec4a421f9bfd698ac070783dd

Authored by tsl0922
1 parent ae006dd9

fix http push 401

Showing 1 changed file with 7 additions and 3 deletions   Show diff stats
lib/gitlab/backend/grack_auth.rb
@@ -76,13 +76,17 @@ module Grack @@ -76,13 +76,17 @@ module Grack
76 end 76 end
77 77
78 def validate_get_request 78 def validate_get_request
79 - project.public || can?(user, :download_code, project) 79 + validate_request(@request.params['service'])
80 end 80 end
81 81
82 def validate_post_request 82 def validate_post_request
83 - if @request.path_info.end_with?('git-upload-pack') 83 + validate_request(File.basename(@request.path))
  84 + end
  85 +
  86 + def validate_request(service)
  87 + if service == 'git-upload-pack'
84 project.public || can?(user, :download_code, project) 88 project.public || can?(user, :download_code, project)
85 - elsif @request.path_info.end_with?('git-receive-pack') 89 + elsif service == 'git-receive-pack'
86 action = if project.protected_branch?(current_ref) 90 action = if project.protected_branch?(current_ref)
87 :push_code_to_protected_branches 91 :push_code_to_protected_branches
88 else 92 else