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

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2019-03-27 21:03:25 +0300
committerJacob Vosmaer <jacob@gitlab.com>2019-03-27 21:03:25 +0300
commitf1a576a747aa5e60279a8ec0eb7c92934af368f5 (patch)
tree988cf50cd4406f70da9e2ea956c93137d2dc2c0b
parent2b4b9eb13008f12efd3d624440125b38729a6ff8 (diff)
Add sketch of HTTP auth integration in FetchRemotejv-sketch-fetch-remote
-rw-r--r--ruby/lib/gitaly_server/repository_service.rb23
-rw-r--r--ruby/lib/gitlab/git/http_auth.rb20
2 files changed, 36 insertions, 7 deletions
diff --git a/ruby/lib/gitaly_server/repository_service.rb b/ruby/lib/gitaly_server/repository_service.rb
index edbe2011f..091e5ad34 100644
--- a/ruby/lib/gitaly_server/repository_service.rb
+++ b/ruby/lib/gitaly_server/repository_service.rb
@@ -21,16 +21,25 @@ module GitalyServer
end
def fetch_remote(request, call)
+ repository = Gitlab::Git::Repository.from_gitaly(request.repository, call)
+
+ if request.remote_params
+ params = request.remote_params
+ repository.add_remote(params.name, params.url)
+ end
+
gitlab_projects = Gitlab::Git::GitlabProjects.from_gitaly(request.repository, call)
success = Gitlab::Git::SshAuth.from_gitaly(request).setup do |env|
- gitlab_projects.fetch_remote(
- request.remote,
- request.timeout,
- force: request.force,
- tags: !request.no_tags,
- env: env
- )
+ Gitlab::Git::HttpAuth.from_gitaly(request) do
+ gitlab_projects.fetch_remote(
+ request.remote,
+ request.timeout,
+ force: request.force,
+ tags: !request.no_tags,
+ env: env
+ )
+ end
end
raise GRPC::Unknown.new("Fetching remote #{request.remote} failed: #{gitlab_projects.output}") unless success
diff --git a/ruby/lib/gitlab/git/http_auth.rb b/ruby/lib/gitlab/git/http_auth.rb
new file mode 100644
index 000000000..135135efe
--- /dev/null
+++ b/ruby/lib/gitlab/git/http_auth.rb
@@ -0,0 +1,20 @@
+module Git
+ module Gitlab
+ class HttpAuth
+ def self.from_gitaly(request)
+ repo = request.repository
+ params = request.remote_params
+ # validate params, don't set config if bad, or raise error?
+
+ key = "http.#{params.url}.extraHeader"
+ repo.rugged.config[key] = params.httpAuth
+
+ begin
+ yield # yield back to fetch_remote RPC handler
+ ensure
+ repo.rugged.config.delete(key)
+ end
+ end
+ end
+ end
+end