Merge "Support [DEFAULT] cors_expose_headers"

This commit is contained in:
Zuul 2024-07-29 08:47:23 +00:00 committed by Gerrit Code Review
commit 968faff446
3 changed files with 25 additions and 11 deletions

View File

@ -128,15 +128,20 @@
# Configures log_name for swift proxy-server.
# Optional. Defaults to proxy-server
#
# [*cors_allow_origin*]
# (optional) Origins to be allowed to make Cross Origin Requests.
# A comma separated list of full url (http://foo.bar:1234,https://foo.bar)
# Defaults to $facts['os_service_default'].
# [*cors_allow_origin*]
# (optional) Origins to be allowed to make Cross Origin Requests.
# A comma separated list of full url (http://foo.bar:1234,https://foo.bar)
# Defaults to $facts['os_service_default'].
#
# [*strict_cors_mode*]
# (optional) If True (default) then CORS requests are only allowed if their
# Origin header matches an allowed origin. Otherwise, any Origin is allowed.
# Defaults to $facts['os_service_default'].
# [*strict_cors_mode*]
# (optional) If True (default) then CORS requests are only allowed if their
# Origin header matches an allowed origin. Otherwise, any Origin is allowed.
# Defaults to $facts['os_service_default'].
#
# [*cors_expose_headers*]
# (optional) List of headers to expose through Access-Control-Expose-Headers,
# in addition to the defaults and any headers set in container metadata.
# Defaults to $facts['os_service_default'].
#
# [*service_provider*]
# (optional)
@ -178,6 +183,7 @@ class swift::proxy(
$log_name = 'proxy-server',
$cors_allow_origin = $facts['os_service_default'],
$strict_cors_mode = $facts['os_service_default'],
$cors_expose_headers = $facts['os_service_default'],
$object_chunk_size = $facts['os_service_default'],
$client_chunk_size = $facts['os_service_default'],
$max_containers_per_account = $facts['os_service_default'],
@ -274,8 +280,9 @@ class swift::proxy(
}
swift_proxy_config {
'DEFAULT/cors_allow_origin': value => join(any2array($cors_allow_origin), ',');
'DEFAULT/strict_cors_mode': value => $strict_cors_mode;
'DEFAULT/cors_allow_origin': value => join(any2array($cors_allow_origin), ',');
'DEFAULT/strict_cors_mode': value => $strict_cors_mode;
'DEFAULT/cors_expose_headers': value => join(any2array($cors_expose_headers), ',');
}
if $write_affinity {

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``swift::proxy::cors_expose_headers`` parameter has been added.

View File

@ -90,6 +90,7 @@ describe 'swift::proxy' do
it { should contain_swift_proxy_config('app:proxy-server/allow_open_expired').with_value('<SERVICE DEFAULT>') }
it { should contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('<SERVICE DEFAULT>') }
it { should contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('<SERVICE DEFAULT>') }
it { should contain_swift_proxy_config('DEFAULT/cors_expose_headers').with_value('<SERVICE DEFAULT>') }
it { should contain_service('swift-proxy-server').with_require([
'Class[Swift::Proxy::Catch_errors]',
@ -152,7 +153,8 @@ describe 'swift::proxy' do
:recoverable_node_timeout => '15',
:allow_open_expired => false,
:cors_allow_origin => ['http://foo.bar:1234', 'https://foo.bar'],
:strict_cors_mode => true
:strict_cors_mode => true,
:cors_expose_headers => ['header-a', 'header-b'],
}
end
@ -189,6 +191,7 @@ describe 'swift::proxy' do
it { should contain_swift_proxy_config('app:proxy-server/allow_open_expired').with_value(false) }
it { should contain_swift_proxy_config('DEFAULT/cors_allow_origin').with_value('http://foo.bar:1234,https://foo.bar') }
it { should contain_swift_proxy_config('DEFAULT/strict_cors_mode').with_value('true') }
it { should contain_swift_proxy_config('DEFAULT/cors_expose_headers').with_value('header-a,header-b') }
end
describe "when log udp port is set" do