Commit eb3533bf authored by Aakriti Gupta's avatar Aakriti Gupta Committed by Michael Kozono

Allow admins to edit application settings during maintenance mode

- allow application settings api endpoint to pass
through read-only middleware
parent 29bccc1f
...@@ -33,7 +33,7 @@ module EE ...@@ -33,7 +33,7 @@ module EE
# secondary either # secondary either
override :allowlisted_routes override :allowlisted_routes
def allowlisted_routes def allowlisted_routes
allowed = super || geo_node_update_route? || geo_api_route? allowed = super || geo_node_update_route? || geo_api_route? || admin_settings_update?
return true if allowed return true if allowed
return false if ::Gitlab.maintenance_mode? return false if ::Gitlab.maintenance_mode?
...@@ -46,6 +46,10 @@ module EE ...@@ -46,6 +46,10 @@ module EE
geo_proxy_git_ssh_route? || geo_proxy_git_http_route? || lfs_locks_route? geo_proxy_git_ssh_route? || geo_proxy_git_http_route? || lfs_locks_route?
end end
def admin_settings_update?
request.path.start_with?('/api/v4/application/settings')
end
def geo_node_update_route? def geo_node_update_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match # Calling route_hash may be expensive. Only do it if we think there's a possible match
return false unless request.path.start_with?('/admin/geo/') return false unless request.path.start_with?('/admin/geo/')
......
...@@ -15,6 +15,13 @@ RSpec.shared_examples 'write access for a read-only GitLab (EE) instance in main ...@@ -15,6 +15,13 @@ RSpec.shared_examples 'write access for a read-only GitLab (EE) instance in main
it_behaves_like 'allowlisted /admin/geo requests' it_behaves_like 'allowlisted /admin/geo requests'
it "expects a PUT request to /admin/application_settings/general to be allowed" do
response = request.send(:put, "/api/v4/application/settings")
expect(response).not_to be_redirect
expect(subject).not_to disallow_request
end
context 'on Geo secondary' do context 'on Geo secondary' do
before do before do
allow(::Gitlab::Geo).to receive(:secondary?).and_return(true) allow(::Gitlab::Geo).to receive(:secondary?).and_return(true)
......
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