Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
c0a5b628
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c0a5b628
编写于
1月 14, 2019
作者:
A
Ash McKenzie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow sidekiq admin requests, regardless of root
上级
a2b26577
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
10 deletion
+34
-10
lib/gitlab/middleware/read_only/controller.rb
lib/gitlab/middleware/read_only/controller.rb
+7
-3
spec/lib/gitlab/middleware/read_only_spec.rb
spec/lib/gitlab/middleware/read_only_spec.rb
+27
-7
未找到文件。
lib/gitlab/middleware/read_only/controller.rb
浏览文件 @
c0a5b628
...
@@ -71,9 +71,13 @@ module Gitlab
...
@@ -71,9 +71,13 @@ module Gitlab
@route_hash
||=
Rails
.
application
.
routes
.
recognize_path
(
request
.
url
,
{
method:
request
.
request_method
})
rescue
{}
@route_hash
||=
Rails
.
application
.
routes
.
recognize_path
(
request
.
url
,
{
method:
request
.
request_method
})
rescue
{}
end
end
def
relative_url
File
.
join
(
''
,
Gitlab
.
config
.
gitlab
.
relative_url_root
).
chomp
(
'/'
)
end
# Overridden in EE module
# Overridden in EE module
def
whitelisted_routes
def
whitelisted_routes
grack_route
||
ReadOnly
.
internal_routes
.
any?
{
|
path
|
request
.
path
.
include?
(
path
)
}
||
lfs_route
||
sidekiq_route
grack_route
||
ReadOnly
.
internal_routes
.
any?
{
|
path
|
request
.
path
.
include?
(
path
)
}
||
lfs_route
||
sidekiq_route
?
end
end
def
grack_route
def
grack_route
...
@@ -95,8 +99,8 @@ module Gitlab
...
@@ -95,8 +99,8 @@ module Gitlab
WHITELISTED_GIT_LFS_ROUTES
[
route_hash
[
:controller
]]
&
.
include?
(
route_hash
[
:action
])
WHITELISTED_GIT_LFS_ROUTES
[
route_hash
[
:controller
]]
&
.
include?
(
route_hash
[
:action
])
end
end
def
sidekiq_route
def
sidekiq_route
?
request
.
path
.
start_with?
(
'/admin/sidekiq'
)
request
.
path
.
start_with?
(
"
#{
relative_url
}
/admin/sidekiq"
)
end
end
end
end
end
end
...
...
spec/lib/gitlab/middleware/read_only_spec.rb
浏览文件 @
c0a5b628
...
@@ -101,16 +101,36 @@ describe Gitlab::Middleware::ReadOnly do
...
@@ -101,16 +101,36 @@ describe Gitlab::Middleware::ReadOnly do
expect
(
subject
).
not_to
disallow_request
expect
(
subject
).
not_to
disallow_request
end
end
it
'expects requests to sidekiq admin to be allowed'
do
context
'sidekiq admin requests'
do
response
=
request
.
post
(
'/admin/sidekiq'
)
where
(
:mounted_at
)
do
[
''
,
'/'
,
'/gitlab'
,
'/gitlab/'
,
'/gitlab/gitlab'
,
'/gitlab/gitlab/'
]
end
expect
(
response
).
not_to
be_redirect
with_them
do
expect
(
subject
).
not_to
disallow_request
before
do
stub_config_setting
(
relative_url_root:
mounted_at
)
end
response
=
request
.
get
(
'/admin/sidekiq'
)
it
'allows requests'
do
path
=
File
.
join
(
mounted_at
,
'admin/sidekiq'
)
response
=
request
.
post
(
path
)
expect
(
response
).
not_to
be_redirect
expect
(
response
).
not_to
be_redirect
expect
(
subject
).
not_to
disallow_request
expect
(
subject
).
not_to
disallow_request
response
=
request
.
get
(
path
)
expect
(
response
).
not_to
be_redirect
expect
(
subject
).
not_to
disallow_request
end
end
end
end
where
(
:description
,
:path
)
do
where
(
:description
,
:path
)
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录