OSDN Git Service

fix http push 401
authortsl0922 <tsl0922@gmail.com>
Fri, 19 Apr 2013 08:43:54 +0000 (16:43 +0800)
committertsl0922 <tsl0922@gmail.com>
Fri, 3 May 2013 02:58:53 +0000 (10:58 +0800)
lib/gitlab/backend/grack_auth.rb

index f46455f..8b43b60 100644 (file)
@@ -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