Открыть боковую панель
nt_test133
nt_project_uxpg8lvcuq8w
Коммиты
921c704f
Коммит
921c704f
создал
Сен 05, 2019
по автору
Brett Walker
Просмотр файлов
Set asset_proxy_whitelist default to gitlab host
владелец
700bdfc7
Изменения
3
Скрыть пробелы
Построчно
Рядом
changelogs/unreleased/67037-user-content-gitlab-static-net-brings-back-404-only.yml
0 → 100644
Просмотр файла @
921c704f
---
title
:
Default the asset proxy whitelist to the installation domain
merge_request
:
32703
author
:
type
:
fixed
lib/banzai/filter/asset_proxy_filter.rb
Просмотр файла @
921c704f
...
@@ -44,7 +44,7 @@ def self.initialize_settings
...
@@ -44,7 +44,7 @@ def self.initialize_settings
Gitlab
.
config
.
asset_proxy
[
'enabled'
]
=
application_settings
.
asset_proxy_enabled
Gitlab
.
config
.
asset_proxy
[
'enabled'
]
=
application_settings
.
asset_proxy_enabled
Gitlab
.
config
.
asset_proxy
[
'url'
]
=
application_settings
.
asset_proxy_url
Gitlab
.
config
.
asset_proxy
[
'url'
]
=
application_settings
.
asset_proxy_url
Gitlab
.
config
.
asset_proxy
[
'secret_key'
]
=
application_settings
.
asset_proxy_secret_key
Gitlab
.
config
.
asset_proxy
[
'secret_key'
]
=
application_settings
.
asset_proxy_secret_key
Gitlab
.
config
.
asset_proxy
[
'whitelist'
]
=
application_settings
.
asset_proxy_whitelist
||
[
Gitlab
.
config
.
gitlab
.
host
]
Gitlab
.
config
.
asset_proxy
[
'whitelist'
]
=
determine_whitelist
(
application_settings
)
Gitlab
.
config
.
asset_proxy
[
'domain_regexp'
]
=
compile_whitelist
(
Gitlab
.
config
.
asset_proxy
.
whitelist
)
Gitlab
.
config
.
asset_proxy
[
'domain_regexp'
]
=
compile_whitelist
(
Gitlab
.
config
.
asset_proxy
.
whitelist
)
else
else
Gitlab
.
config
.
asset_proxy
[
'enabled'
]
=
::
ApplicationSetting
.
defaults
[
:asset_proxy_enabled
]
Gitlab
.
config
.
asset_proxy
[
'enabled'
]
=
::
ApplicationSetting
.
defaults
[
:asset_proxy_enabled
]
...
@@ -57,6 +57,10 @@ def self.compile_whitelist(domain_list)
...
@@ -57,6 +57,10 @@ def self.compile_whitelist(domain_list)
escaped
=
domain_list
.
map
{
|
domain
|
Regexp
.
escape
(
domain
).
gsub
(
'\*'
,
'.*?'
)
}
escaped
=
domain_list
.
map
{
|
domain
|
Regexp
.
escape
(
domain
).
gsub
(
'\*'
,
'.*?'
)
}
Regexp
.
new
(
"^(
#{
escaped
.
join
(
'|'
)
}
)$"
,
Regexp
::
IGNORECASE
)
Regexp
.
new
(
"^(
#{
escaped
.
join
(
'|'
)
}
)$"
,
Regexp
::
IGNORECASE
)
end
end
def
self
.
determine_whitelist
(
application_settings
)
application_settings
.
asset_proxy_whitelist
.
presence
||
[
Gitlab
.
config
.
gitlab
.
host
]
end
end
end
end
end
end
end
spec/lib/banzai/filter/asset_proxy_filter_spec.rb
Просмотр файла @
921c704f
...
@@ -36,6 +36,17 @@ def image(path)
...
@@ -36,6 +36,17 @@ def image(path)
expect
(
Gitlab
.
config
.
asset_proxy
.
whitelist
).
to
eq
%w(gitlab.com *.mydomain.com)
expect
(
Gitlab
.
config
.
asset_proxy
.
whitelist
).
to
eq
%w(gitlab.com *.mydomain.com)
expect
(
Gitlab
.
config
.
asset_proxy
.
domain_regexp
).
to
eq
/^(gitlab\.com|.*?\.mydomain\.com)$/i
expect
(
Gitlab
.
config
.
asset_proxy
.
domain_regexp
).
to
eq
/^(gitlab\.com|.*?\.mydomain\.com)$/i
end
end
context
'when whitelist is empty'
do
it
'defaults to the install domain'
do
stub_application_setting
(
asset_proxy_enabled:
true
)
stub_application_setting
(
asset_proxy_whitelist:
[])
described_class
.
initialize_settings
expect
(
Gitlab
.
config
.
asset_proxy
.
whitelist
).
to
eq
[
Gitlab
.
config
.
gitlab
.
host
]
end
end
end
end
context
'when properly configured'
do
context
'when properly configured'
do
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать