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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
de1fc6f1
Commit
de1fc6f1
authored
Dec 06, 2021
by
Dmitry Gruzd
Committed by
Mark Chao
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix global anonymous searches restriction
parent
6adff1dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
app/controllers/search_controller.rb
app/controllers/search_controller.rb
+2
-2
app/services/search_service.rb
app/services/search_service.rb
+4
-0
spec/controllers/search_controller_spec.rb
spec/controllers/search_controller_spec.rb
+6
-0
No files found.
app/controllers/search_controller.rb
View file @
de1fc6f1
...
...
@@ -150,7 +150,7 @@ class SearchController < ApplicationController
end
def
block_anonymous_global_searches
return
if
params
[
:project_id
].
present?
||
params
[
:group_id
].
present
?
return
unless
search_service
.
global_search
?
return
if
current_user
return
unless
::
Feature
.
enabled?
(
:block_anonymous_global_searches
,
type: :ops
)
...
...
@@ -160,7 +160,7 @@ class SearchController < ApplicationController
end
def
check_scope_global_search_enabled
return
if
params
[
:project_id
].
present?
||
params
[
:group_id
].
present
?
return
unless
search_service
.
global_search
?
search_allowed
=
case
params
[
:scope
]
when
'blobs'
...
...
app/services/search_service.rb
View file @
de1fc6f1
...
...
@@ -45,6 +45,10 @@ class SearchService
# overridden in EE
end
def
global_search?
project
.
blank?
&&
group
.
blank?
end
def
show_snippets?
return
@show_snippets
if
defined?
(
@show_snippets
)
...
...
spec/controllers/search_controller_spec.rb
View file @
de1fc6f1
...
...
@@ -172,6 +172,12 @@ RSpec.describe SearchController do
expect
(
response
).
to
redirect_to
new_user_session_path
end
it
'redirects to login page when trying to circumvent the restriction'
do
get
:show
,
params:
{
scope:
'projects'
,
project_id:
non_existing_record_id
,
search:
'*'
}
expect
(
response
).
to
redirect_to
new_user_session_path
end
end
context
'for authenticated user'
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