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

**URL:** https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952
**Category:** Support
**Created:** [19 ביוני,‏ 2025,‏ 9:19pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952 "2025-06-19T21:19:09Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [19 ביוני,‏ 2025,‏ 9:19pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/1 "2025-06-19T21:19:09Z")

</div>

היי, הייתי רוצה לבנות מחדש את האפליקציה כולל שינוי בקובץ מסוים כדי להשבית את תכונת החיפוש למשתמשים אנונימיים. (יותר מסתם עם 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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [21 ביוני,‏ 2025,‏ 2:05am UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/2 "2025-06-21T02:05:30Z")

</div>

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

```plaintext
rate_limit_search_anon_global_per_minute

```

---

<div class="post-metadata">

### Author: ![Michael12](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michael12/32/507366_2.png) [@Michael12](https://meta.discourse.org/u/Michael12)
#### Post date: [21 ביוני,‏ 2025,‏ 2:11am UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/3 "2025-06-21T02:11:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [21 ביוני,‏ 2025,‏ 9:57am UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/4 "2025-06-21T09:57:21Z")

</div>

Thanks for providing with the variable, with this [documentation](https://meta.discourse.org/t/using-hidden-site-settings/308773) I could make it work.

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

```plaintext
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 :

```plaintext
.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.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [21 ביוני,‏ 2025,‏ 4:05pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/5 "2025-06-21T16:05:42Z")

</div>

> [@opcourdis](#):
>
> 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?

As in log in to do searches?

On the OP you specified that you want to

> [@opcourdis](#):
>
> disable the search feature for anonymous users.

And this is what this setting does.

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

---

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [21 ביוני,‏ 2025,‏ 5:04pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/6 "2025-06-21T17:04:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [21 ביוני,‏ 2025,‏ 9:53pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/7 "2025-06-21T21:53:08Z")

</div>

> [@opcourdis](#):
>
> I mean non logged in user that would create a session cookie to pretend they are logged in

🤨

That would be a security issue. If you can achieve that make sure to report to [HackerOne](https://hackerone.com/discourse)

> [@opcourdis](#):
>
> but maybe I am fetching a bit too far here

![](https://media.tenor.com/w_DGRPsvzZAAAAAC/team-fortress2-heavy.gif)

---

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [21 ביוני,‏ 2025,‏ 10:04pm UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/8 "2025-06-21T22:04:08Z")

</div>

" That would be a security issue. If you can achieve that make sure to report to [HackerOne](https://hackerone.com/discourse)"

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

---

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [23 ביוני,‏ 2025,‏ 8:43am UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/9 "2025-06-23T08:43:02Z")

</div>

DISCOURSE\_RATE\_LIMIT\_SEARCH\_ANON\_GLOBAL\_PER\_MINUTE: 0

```plaintext
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.

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [23 ביולי,‏ 2025,‏ 8:43am UTC](https://meta.discourse.org/t/hooks-from-to-syntax-in-yml-to-disable-anonymous-searches/370952/10 "2025-07-23T08:43:55Z")

</div>

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