Skip to content
Snippets Groups Projects
Commit 006e6b7d1265 authored by Timo Furrer's avatar Timo Furrer
Browse files

Allow external GitLab URL configuration for KAS

Add configuration key to set `gitlab.external_url` in KAS in support of
cross origin resource sharing (CORS) requests.

Changelog: changed
parent 4accb77b78ab
No related branches found
No related tags found
3 merge requests!102heptapod#1237: making 0.38 the new oldstable,!96Merged heptapod branch for upstream 15.11 in heptapod-stable,!93Merged upstream 15.11.0+rc42+ce.0
......@@ -9,6 +9,7 @@
default['gitlab_kas']['agent_info_cache_ttl'] = 300
default['gitlab_kas']['agent_info_cache_error_ttl'] = 60
default['gitlab_kas']['gitlab_address'] = ''
default['gitlab_kas']['gitlab_external_url'] = nil
default['gitlab_kas']['api_secret_key'] = nil
default['gitlab_kas']['listen_address'] = 'localhost:8150'
default['gitlab_kas']['listen_network'] = 'tcp'
......
......@@ -21,6 +21,7 @@
class << self
def parse_variables
parse_address
parse_gitlab_external_url
parse_gitlab_kas_enabled
parse_gitlab_kas_external_url
parse_gitlab_kas_internal_url
......@@ -78,6 +79,14 @@
end
end
def parse_gitlab_external_url
return if Gitlab['external_url'].nil?
gitlab_uri = URI(Gitlab['external_url'])
Gitlab['gitlab_kas']['gitlab_external_url'] ||= "#{gitlab_uri.scheme}://#{gitlab_uri.host}"
end
def parse_secrets
# KAS and GitLab expects exactly 32 bytes, encoded with base64
......
......@@ -25,6 +25,7 @@
info_cache_error_ttl: <%= @agent_info_cache_error_ttl %>s
gitlab:
address: <%= @gitlab_address %>
external_url: <%= @gitlab_external_url %>
authentication_secret_file: <%= @authentication_secret_file %>
observability:
listen:
......
......@@ -72,7 +72,10 @@
authentication_secret_file: "/var/opt/gitlab/gitlab-kas/private_api_authentication_secret_file",
network: "tcp"
},
}
},
gitlab: hash_including(
external_url: 'https://gitlab.example.com'
)
)
)
end
......@@ -243,6 +246,16 @@
external_k8s_proxy_url: 'https://example.com/gitlab/-/kubernetes-agent/k8s-proxy/'
)
end
it 'renders KAS config gitlab external URL correctly' do
expect(gitlab_kas_config_yml).to(
include(
gitlab: hash_including(
external_url: 'https://example.com'
)
)
)
end
end
context 'with kas url using own sub-domain' do
......@@ -298,6 +311,22 @@
"gitlab_kas_external_url scheme must be 'ws' or 'wss'"
)
end
it 'renders KAS config gitlab external URL correctly' do
stub_gitlab_rb(
external_url: 'https://gitlab.example.com',
gitlab_kas_external_url: 'wss://kas.gitlab.example.com/',
gitlab_kas: { listen_websocket: true }
)
expect(gitlab_kas_config_yml).to(
include(
gitlab: hash_including(
external_url: 'https://gitlab.example.com'
)
)
)
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment