Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-08-29 01:04:06 +0400
committerrandx <dmitriy.zaporozhets@gmail.com>2012-08-29 01:04:06 +0400
commit7cdc5b9e0438c35c83fce739a764cb146d20c004 (patch)
tree42cfe847873dee51c54d32c81a8543c2d75fce50 /config
parentaded7056fd3a9830215f41233ef609c0f9a3b862 (diff)
Use similar interface to access gitolite
Simplified gitolite handle logic Stubn over monkeypatch Stub only specific methods in Gitlab:Gitolite Moved grach auth to lib added specs for keys observer removes SshKey role
Diffstat (limited to 'config')
-rw-r--r--config/environment.rb2
-rw-r--r--config/initializers/5_backend.rb5
-rw-r--r--config/initializers/grack_auth.rb54
3 files changed, 5 insertions, 56 deletions
diff --git a/config/environment.rb b/config/environment.rb
index c880a7adc42..3b186a9d57a 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -3,5 +3,3 @@ require File.expand_path('../application', __FILE__)
# Initialize the rails application
Gitlab::Application.initialize!
-
-require File.join(Rails.root, "lib", "gitlab", "git_host")
diff --git a/config/initializers/5_backend.rb b/config/initializers/5_backend.rb
new file mode 100644
index 00000000000..85f747ac334
--- /dev/null
+++ b/config/initializers/5_backend.rb
@@ -0,0 +1,5 @@
+# GIT over HTTP
+require Rails.root.join("lib", "gitlab", "backend", "grack_auth")
+
+# GITOLITE backend
+require Rails.root.join("lib", "gitlab", "backend", "gitolite")
diff --git a/config/initializers/grack_auth.rb b/config/initializers/grack_auth.rb
deleted file mode 100644
index 4f77c327373..00000000000
--- a/config/initializers/grack_auth.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-module Grack
- class Auth < Rack::Auth::Basic
-
- def valid?
- # Authentication with username and password
- email, password = @auth.credentials
- user = User.find_by_email(email)
- return false unless user.try(:valid_password?, password)
-
- # Set GL_USER env variable
- ENV['GL_USER'] = email
- # Pass Gitolite update hook
- ENV['GL_BYPASS_UPDATE_HOOK'] = "true"
-
- # Need this patch because the rails mount
- @env['PATH_INFO'] = @env['REQUEST_PATH']
-
- # Find project by PATH_INFO from env
- if m = /^\/([\w-]+).git/.match(@env['PATH_INFO']).to_a
- return false unless project = Project.find_by_path(m.last)
- end
-
- # Git upload and receive
- if @env['REQUEST_METHOD'] == 'GET'
- true
- elsif @env['REQUEST_METHOD'] == 'POST'
- if @env['REQUEST_URI'].end_with?('git-upload-pack')
- return project.dev_access_for?(user)
- elsif @env['REQUEST_URI'].end_with?('git-receive-pack')
- if project.protected_branches.map(&:name).include?(current_ref)
- project.master_access_for?(user)
- else
- project.dev_access_for?(user)
- end
- else
- false
- end
- else
- false
- end
- end# valid?
-
- def current_ref
- if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/
- input = Zlib::GzipReader.new(@request.body).read
- else
- input = @request.body.read
- end
- # Need to reset seek point
- @request.body.rewind
- /refs\/heads\/([\w-]+)/.match(input).to_a.first
- end
- end# Auth
-end# Grack