Hooks מ: & ל: תחביר ב-yml

היי, הייתי רוצה לבנות מחדש את האפליקציה כולל שינוי בקובץ מסוים כדי להשבית את תכונת החיפוש למשתמשים אנונימיים. (יותר מסתם עם CSS)

האם מישהו יכול לספק לי תיעוד לתחביר של ה-hooks האלה עבור החלק של from: ו-to:?

replace
filename:“/var/www/discourse/app/controllers/search_controller.rb”
from:
to:

ב-search_controller.rb, אני רק רוצה להחליף את שורה 12 ב-
def show
ב-
def show
if current_user.present?

ושורה 76
format.json { render_json_dump(serializer) }
ב-
format.json { render_json_dump(serializer) }
end

ישנה הגדרת אתר נסתרת כדי להשיג זאת:

rate_limit_search_anon_global_per_minute
לייק 1

תודה שהצבעת על כך. רק כדי להבהיר, מה שם הגדרת האתר הנסתר? והאם היא משביתה לחלוטין את החיפוש עבור משתמשים אנונימיים, או רק מסתירה את התוצאות? אני מחפש דרך לחסום גישה ברמת הבקר (controller), אז תוהה אם ההגדרה הזו לבדה מספיקה או שעדיין נדרש קוד מותאם אישית.

Thanks for providing with the variable, with this documentation I could make it work.

So I modified the app.yml with the following, saved, then ./launcher restart app(no rebuild needed)

env:
  DISCOURSE_RATE_LIMIT_SEARCH_ANON_GLOBAL_PER_MINUTE: 0

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 :

.anon #search-button {
	display: none !important;
}

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.

As in log in to do searches?

On the OP you specified that you want to

And this is what this setting does.

Of course it won’t affect uses who are logged in.

אני מתכוון למשתמש שאינו מחובר, שיצור עוגיית סשן כדי להתחזות למחובר, אבל אולי אני חושב רחוק מדי כאן, כיוון שאני מניח שפונקציית currentUser בודקת את מפתח הסשן.

:face_with_raised_eyebrow:

That would be a security issue. If you can achieve that make sure to report to HackerOne

לייק 1

" 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 :slight_smile: , I was just asking, maybe there was some discourse engineer around :slight_smile: ; anyway, we got our solution to this thread thanks to you Falco

לייק 1

DISCOURSE_RATE_LIMIT_SEARCH_ANON_GLOBAL_PER_MINUTE: 0

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.