Skip to content
Snippets Groups Projects
Commit 6d271b444801 authored by leetickett's avatar leetickett
Browse files

Fix alternate port support in gitlab pages

Resolves bug where user custom port settings were not honored for
gitlab pages.

Changelog: fixed
parent d55740322582
No related branches found
No related tags found
2 merge requests!39Bumped oldstable branch to Heptapod 0.21,!31GitLab 13.10
---
title: Fix gitlab pages on alternate port
merge_request: 5070
author: Lee Tickett @leetickett
type: fixed
......@@ -76,4 +76,8 @@
Gitlab['gitlab_pages']['gitlab_server'] ||= Gitlab['external_url']
Gitlab['gitlab_pages']['artifacts_server_url'] ||= Gitlab['gitlab_pages']['gitlab_server'].chomp('/') + '/api/v4'
parse_auth_redirect_uri
end
def parse_auth_redirect_uri
return unless Gitlab['gitlab_pages']['access_control']
......@@ -79,3 +83,4 @@
return unless Gitlab['gitlab_pages']['access_control']
return if Gitlab['gitlab_pages']['auth_redirect_uri']
pages_uri = URI(Gitlab['pages_external_url'].to_s)
......@@ -80,6 +85,7 @@
pages_uri = URI(Gitlab['pages_external_url'].to_s)
Gitlab['gitlab_pages']['auth_redirect_uri'] ||= pages_uri.scheme + '://projects.' + pages_uri.host + '/auth'
parsed_port = [80, 443].include?(pages_uri.port) ? "" : ":#{pages_uri.port}"
Gitlab['gitlab_pages']['auth_redirect_uri'] = pages_uri.scheme + '://projects.' + pages_uri.host + parsed_port + '/auth'
end
def authorize_with_gitlab
......
......@@ -155,6 +155,23 @@
end
end
context 'with custom port' do
before do
stub_gitlab_rb(
pages_external_url: 'https://pages.example.com:8443',
gitlab_pages: {
access_control: true
}
)
end
it 'sets the correct port number' do
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-pages/gitlab-pages-config").with_content { |content|
expect(content).to match(%r{auth-redirect-uri=https://projects.pages.example.com:8443/auth})
}
end
end
context 'with custom values' do
before do
stub_gitlab_rb(
......
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