diff options
author | Egor Kislitsyn <egor@kislitsyn.com> | 2019-06-11 14:28:39 +0700 |
---|---|---|
committer | Egor Kislitsyn <egor@kislitsyn.com> | 2019-06-11 14:28:39 +0700 |
commit | bc8f0593670452851d5e9d97bea1ae90f10db354 (patch) | |
tree | 96aadebecc684b7366f8d5d5811fa3ffe4d4f1b9 | |
parent | 2e5affce61a9255602d3a5d4c5caced9f09b1f5a (diff) | |
download | pleroma-bc8f0593670452851d5e9d97bea1ae90f10db354.tar.gz |
Add rate limiting for search endpoints
-rw-r--r-- | config/config.exs | 2 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/config/config.exs b/config/config.exs index 4e2b1703b..d20d4fda9 100644 --- a/config/config.exs +++ b/config/config.exs @@ -503,6 +503,8 @@ config :pleroma, :database, rum_enabled: false config :http_signatures, adapter: Pleroma.Signature +config :pleroma, :rate_limit, search: [{1000, 10}, {1000, 30}] + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 92cd77f62..20b08fda4 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -55,6 +55,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do when action in [:account_register] ) + plug(Pleroma.Plugs.RateLimiter, :search when action in [:search, :search2, :account_search]) + @local_mastodon_name "Mastodon-Local" action_fallback(:errors) |