summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-07-29 12:19:59 +0300
committerValery Sizov <vsv2711@gmail.com>2015-07-29 12:19:59 +0300
commit8bda433734394af7e3858c0804b378a6d1313a84 (patch)
tree18287bcfba6fa853f49b6717baf4b8f7bd6a7217 /lib/gitlab
parent81c71d2519cef11bd94ad570d1d4e0e6ca4d71f1 (diff)
parentd64ae5363fc17bf5592bc1a66a53763ddb9a3acc (diff)
downloadgitlab-ce-8bda433734394af7e3858c0804b378a6d1313a84.tar.gz
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/backend/grack_auth.rb11
-rw-r--r--lib/gitlab/backend/shell_env.rb11
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb
index 03cef30c97d..12292f614e9 100644
--- a/lib/gitlab/backend/grack_auth.rb
+++ b/lib/gitlab/backend/grack_auth.rb
@@ -26,7 +26,12 @@ module Grack
auth!
if project && authorized_request?
- @app.call(env)
+ if ENV['GITLAB_GRACK_AUTH_ONLY'] == '1'
+ # Tell gitlab-git-http-server the request is OK, and what the GL_ID is
+ render_grack_auth_ok
+ else
+ @app.call(env)
+ end
elsif @user.nil? && !@gitlab_ci
unauthorized
else
@@ -174,6 +179,10 @@ module Grack
end
end
+ def render_grack_auth_ok
+ [200, { "Content-Type" => "application/json" }, [JSON.dump({ 'GL_ID' => Gitlab::ShellEnv.gl_id(@user) })]]
+ end
+
def render_not_found
[404, { "Content-Type" => "text/plain" }, ["Not Found"]]
end
diff --git a/lib/gitlab/backend/shell_env.rb b/lib/gitlab/backend/shell_env.rb
index 17ec029eed4..9f5adee594a 100644
--- a/lib/gitlab/backend/shell_env.rb
+++ b/lib/gitlab/backend/shell_env.rb
@@ -7,7 +7,7 @@ module Gitlab
def set_env(user)
# Set GL_ID env variable
if user
- ENV['GL_ID'] = "user-#{user.id}"
+ ENV['GL_ID'] = gl_id(user)
end
end
@@ -15,5 +15,14 @@ module Gitlab
# Reset GL_ID env variable
ENV['GL_ID'] = nil
end
+
+ def gl_id(user)
+ if user.present?
+ "user-#{user.id}"
+ else
+ # This empty string is used in the render_grack_auth_ok method
+ ""
+ end
+ end
end
end