Skip to content

Commit ba9ca69

Browse files
ibaumngala
andcommitted
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 <[email protected]> Approved-by: Vladimir Shushlin <[email protected]> Approved-by: Mitchell Nielsen <[email protected]> Approved-by: Ian Baum <[email protected]> Co-authored-by: ngala <[email protected]>
2 parents 82c190a + 1f59713 commit ba9ca69

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

files/gitlab-cookbooks/gitlab-pages/libraries/gitlab_pages.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ def parse_auth_redirect_uri
8989

9090
pages_uri = URI(Gitlab['pages_external_url'].to_s)
9191
parsed_port = [80, 443].include?(pages_uri.port) ? "" : ":#{pages_uri.port}"
92-
Gitlab['gitlab_pages']['auth_redirect_uri'] = pages_uri.scheme + '://projects.' + pages_uri.host + parsed_port + '/auth'
92+
93+
Gitlab['gitlab_pages']['auth_redirect_uri'] = if Gitlab['gitlab_pages']['namespace_in_path']
94+
"#{pages_uri.scheme}://#{pages_uri.host}#{parsed_port}/projects/auth"
95+
else
96+
"#{pages_uri.scheme}://projects.#{pages_uri.host}#{parsed_port}/auth"
97+
end
9398
end
9499

95100
def authorize_with_gitlab

spec/chef/cookbooks/gitlab-pages/recipes/gitlab-pages_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,44 @@
169169
chef_run
170170
end
171171
end
172+
173+
context 'when namespace in path is enabled' do
174+
before do
175+
stub_gitlab_rb(
176+
pages_external_url: 'https://pages.example.com',
177+
gitlab_pages: {
178+
access_control: true,
179+
namespace_in_path: true,
180+
}
181+
)
182+
end
183+
184+
it 'renders pages config file with default auth-redirect-uri' do
185+
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-pages/gitlab-pages-config").with_content { |content|
186+
expect(content).to match(%r{auth-redirect-uri=https://pages.example.com/projects/auth})
187+
expect(content).to match(%r{namespace-in-path=true})
188+
}
189+
end
190+
end
191+
192+
context 'with custom port and namespace in path is enabled' do
193+
before do
194+
stub_gitlab_rb(
195+
pages_external_url: 'https://pages.example.com:8443',
196+
gitlab_pages: {
197+
access_control: true,
198+
namespace_in_path: true,
199+
}
200+
)
201+
end
202+
203+
it 'renders pages config file with default auth-redirect-uri' do
204+
expect(chef_run).to render_file("/var/opt/gitlab/gitlab-pages/gitlab-pages-config").with_content { |content|
205+
expect(content).to match(%r{auth-redirect-uri=https://pages.example.com:8443/projects/auth})
206+
expect(content).to match(%r{namespace-in-path=true})
207+
}
208+
end
209+
end
172210
end
173211

174212
context 'with custom port' do

0 commit comments

Comments
 (0)