Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
c0a5b628
Commit
c0a5b628
authored
Jan 14, 2019
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow sidekiq admin requests, regardless of root
parent
a2b26577
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+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
No files found.
lib/gitlab/middleware/read_only/controller.rb
View file @
c0a5b628
...
...
@@ -71,9 +71,13 @@ module Gitlab
@route_hash
||=
Rails
.
application
.
routes
.
recognize_path
(
request
.
url
,
{
method:
request
.
request_method
})
rescue
{}
end
def
relative_url
File
.
join
(
''
,
Gitlab
.
config
.
gitlab
.
relative_url_root
).
chomp
(
'/'
)
end
# Overridden in EE module
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
def
grack_route
...
...
@@ -95,8 +99,8 @@ module Gitlab
WHITELISTED_GIT_LFS_ROUTES
[
route_hash
[
:controller
]]
&
.
include?
(
route_hash
[
:action
])
end
def
sidekiq_route
request
.
path
.
start_with?
(
'/admin/sidekiq'
)
def
sidekiq_route
?
request
.
path
.
start_with?
(
"
#{
relative_url
}
/admin/sidekiq"
)
end
end
end
...
...
spec/lib/gitlab/middleware/read_only_spec.rb
View file @
c0a5b628
...
...
@@ -101,16 +101,36 @@ describe Gitlab::Middleware::ReadOnly do
expect
(
subject
).
not_to
disallow_request
end
it
'expects requests to sidekiq admin to be allowed'
do
response
=
request
.
post
(
'/admin/sidekiq'
)
context
'sidekiq admin requests'
do
where
(
:mounted_at
)
do
[
''
,
'/'
,
'/gitlab'
,
'/gitlab/'
,
'/gitlab/gitlab'
,
'/gitlab/gitlab/'
]
end
expect
(
response
).
not_to
be_redirect
expect
(
subject
).
not_to
disallow_request
with_them
do
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
(
subject
).
not_to
disallow_request
expect
(
response
).
not_to
be_redirect
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
where
(
:description
,
:path
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment