Merge branch 'ngala/namespace-in-path-auth-redirect-uri' into 'master'
Update default pages auth-redirect-uri when namespace-in-path is enabled See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7548 Merged-by: Ian Baum <ibaum@gitlab.com> Approved-by: Vladimir Shushlin <vshushlin@gitlab.com> Approved-by: Mitchell Nielsen <mnielsen@gitlab.com> Approved-by: Ian Baum <ibaum@gitlab.com> Co-authored-by: ngala <ngala@gitlab.com>
This commit is contained in:
commit
ba9ca699aa
|
@ -89,7 +89,12 @@ module GitlabPages
|
||||||
|
|
||||||
pages_uri = URI(Gitlab['pages_external_url'].to_s)
|
pages_uri = URI(Gitlab['pages_external_url'].to_s)
|
||||||
parsed_port = [80, 443].include?(pages_uri.port) ? "" : ":#{pages_uri.port}"
|
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'
|
|
||||||
|
Gitlab['gitlab_pages']['auth_redirect_uri'] = if Gitlab['gitlab_pages']['namespace_in_path']
|
||||||
|
"#{pages_uri.scheme}://#{pages_uri.host}#{parsed_port}/projects/auth"
|
||||||
|
else
|
||||||
|
"#{pages_uri.scheme}://projects.#{pages_uri.host}#{parsed_port}/auth"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorize_with_gitlab
|
def authorize_with_gitlab
|
||||||
|
|
|
@ -169,6 +169,44 @@ RSpec.describe 'gitlab::gitlab-pages' do
|
||||||
chef_run
|
chef_run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when namespace in path is enabled' do
|
||||||
|
before do
|
||||||
|
stub_gitlab_rb(
|
||||||
|
pages_external_url: 'https://pages.example.com',
|
||||||
|
gitlab_pages: {
|
||||||
|
access_control: true,
|
||||||
|
namespace_in_path: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders pages config file with default auth-redirect-uri' 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://pages.example.com/projects/auth})
|
||||||
|
expect(content).to match(%r{namespace-in-path=true})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with custom port and namespace in path is enabled' do
|
||||||
|
before do
|
||||||
|
stub_gitlab_rb(
|
||||||
|
pages_external_url: 'https://pages.example.com:8443',
|
||||||
|
gitlab_pages: {
|
||||||
|
access_control: true,
|
||||||
|
namespace_in_path: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders pages config file with default auth-redirect-uri' 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://pages.example.com:8443/projects/auth})
|
||||||
|
expect(content).to match(%r{namespace-in-path=true})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with custom port' do
|
context 'with custom port' do
|
||||||
|
|
Loading…
Reference in New Issue