Commit c6979035 authored by Ahmad Hassan's avatar Ahmad Hassan

Support tls communication in gitaly

parent 4845401f
...@@ -429,6 +429,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour ...@@ -429,6 +429,7 @@ Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
# Gitaly # Gitaly
# #
Settings['gitaly'] ||= Settingslogic.new({}) Settings['gitaly'] ||= Settingslogic.new({})
Settings.gitaly['tls'] ||= Settingslogic.new({})
# #
# Webpack settings # Webpack settings
......
...@@ -53,6 +53,10 @@ module Gitlab ...@@ -53,6 +53,10 @@ module Gitlab
base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil) base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil)
end end
def self.creds
Gitlab.config.gitaly.tls.credentials
end
def self.stub(name, storage) def self.stub(name, storage)
MUTEX.synchronize do MUTEX.synchronize do
@stubs ||= {} @stubs ||= {}
...@@ -60,9 +64,18 @@ module Gitlab ...@@ -60,9 +64,18 @@ module Gitlab
@stubs[storage][name] ||= begin @stubs[storage][name] ||= begin
klass = stub_class(name) klass = stub_class(name)
addr = stub_address(storage) addr = stub_address(storage)
klass.new(addr, :this_channel_is_insecure) creds = stub_creds(storage)
klass.new(addr, creds)
end
end end
end end
def self.stub_creds(storage)
if URI(address(storage)).scheme == 'tls'
GRPC::Code::ChannelCredentials.new
else
:this_channel_is_insecure
end
end end
def self.stub_class(name) def self.stub_class(name)
...@@ -75,7 +88,7 @@ module Gitlab ...@@ -75,7 +88,7 @@ module Gitlab
def self.stub_address(storage) def self.stub_address(storage)
addr = address(storage) addr = address(storage)
addr = addr.sub(%r{^tcp://}, '') if URI(addr).scheme == 'tcp' addr = addr.sub(%r{^tcp://|^tls://}, '') if %w(tcp tls).include? URI(addr).scheme
addr addr
end end
...@@ -98,8 +111,8 @@ module Gitlab ...@@ -98,8 +111,8 @@ module Gitlab
raise "storage #{storage.inspect} is missing a gitaly_address" raise "storage #{storage.inspect} is missing a gitaly_address"
end end
unless URI(address).scheme.in?(%w(tcp unix)) unless URI(address).scheme.in?(%w(tcp unix tls))
raise "Unsupported Gitaly address: #{address.inspect} does not use URL scheme 'tcp' or 'unix'" raise "Unsupported Gitaly address: #{address.inspect} does not use URL scheme 'tcp' or 'unix' or 'tls'"
end end
address address
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment