The user opcourdis wanted to disable the search feature for anonymous users in Discourse and initially attempted to do so using hooks in app.yml with a replace command, but encountered an error [/#370952/1]. They were then directed to a hidden site setting, DISCOURSE_RATE_LIMIT_SEARCH_ANON_GLOBAL_PER_MINUTE, by Falco and Michael12, which, when set to 0, effectively disables search for anonymous users [/#370952/4]. This results in the search page being unreachable and the search button returning a rate limit error. opcourdis also suggests hiding the search button with CSS.
Further security considerations were raised regarding the possibility of bypassing this restriction through session cookies [/#370952/5], which Falco acknowledged as a potential security issue and encouraged reporting to HackerOne. opcourdis clarified they were simply exploring potential vulnerabilities. A more thorough, but ultimately not persistent after a restart, solution involved modifying the search_controller.rb file [/#370952/4]. Finally, opcourdis expresses gratitude for Falco’s assistance, and offers the controller modification again as a more thorough approach [/#370952/9].
תודה שהצבעת על כך. רק כדי להבהיר, מה שם הגדרת האתר הנסתר? והאם היא משביתה לחלוטין את החיפוש עבור משתמשים אנונימיים, או רק מסתירה את התוצאות? אני מחפש דרך לחסום גישה ברמת הבקר (controller), אז תוהה אם ההגדרה הזו לבדה מספיקה או שעדיין נדרש קוד מותאם אישית.
Now the /search page is unreachable = great
Now the front end search button instantly returns : you’ve performed this action too many times = great
You may hide the search button with :
But the question is : is this thorough? Can anyone just create a simple session cookie to make it look like they are connected so that they can access the content of the site through searches?
More thorough but uncomplete solution :
The file is : /var/www/discourse/app/controllers/search_controller.rb
The modification : add “if current_user.present?” after “def show” and add an “end” at the bottom of the condition.
However I could not make it persistent after restart, so anybody is welcome to tell how to make it persistent after restart with the app.yml hooks after_code replace: feature.
אני מתכוון למשתמש שאינו מחובר, שיצור עוגיית סשן כדי להתחזות למחובר, אבל אולי אני חושב רחוק מדי כאן, כיוון שאני מניח שפונקציית currentUser בודקת את מפתח הסשן.
" That would be a security issue. If you can achieve that make sure to report to HackerOne"
No, I am new to discourse, I cannot even quote properly , I was just asking, maybe there was some discourse engineer around ; anyway, we got our solution to this thread thanks to you Falco
but feel free to try this at the controller level:
/var/www/discourse/app/controllers/search_controller.rb
The modification: add "if current_user.present?" after "def show" and add an "end" at the bottom of the condition.