zulip/zproject
Mateusz Mandera 1901775383 email_mirror: Add realm-based rate limiting.
Closes #2420

We add rate limiting (max X emails withing Y seconds per realm) to the
email mirror. By creating RateLimitedRealmMirror class, inheriting from
RateLimitedObject, and rate_limit_mirror_by_realm function, following a
mechanism used by rate_limit_user, we're able to have this
implementation mostly rely on the already existing, and proven over
time, rate_limiter.py code. The rules are configurable in settings.py in
RATE_LIMITING_MIRROR_REALM_RULES, analogically to RATE_LIMITING_RULES.

Rate limit verification happens in the MirrorWorker in
queue_processors.py. We don't rate limit missed message emails, as due
to using one time addresses, they're not a spam threat.

test_mirror_worker is adapted to the altered MirrorWorker code and a new
test - test_mirror_worker_rate_limiting is added in test_queue_worker.py
to provide coverage for these changes.
2019-03-18 11:16:58 -07:00
..
jinja2 templates: Add django timesince filter to jinja2 filters. 2019-03-11 12:01:11 -07:00
__init__.py Rename Django project to zproject. 2013-08-07 11:04:03 -04:00
backends.py backends: Further optimize auth_enabled_helper. 2019-03-17 15:14:06 -07:00
dev_settings.py settings: Fix definition of DEPLOY_ROOT in dev_settings too. 2019-03-04 18:46:13 -08:00
dev_urls.py tooling: Move confirmation_key view to development only views. 2019-01-11 12:45:21 -08:00
email_backends.py tools: Upgrade Pycodestyle and fix new linter errors. 2019-01-31 12:21:41 -08:00
legacy_urls.py urls: Move the json/fetch_api_key endpoint to be an API-style route. 2018-01-08 13:15:52 -05:00
prod_settings_template.py settings: Rename "user avatar" to "profile picture" 2019-03-15 13:29:56 -07:00
settings.py email_mirror: Add realm-based rate limiting. 2019-03-18 11:16:58 -07:00
slack_importer_test_settings.py settings: Migrate test settings to modern postgres backend name. 2019-01-23 17:08:24 -08:00
terms.md.template Add TERMS_OF_SERVICE setting. 2016-07-29 20:47:31 -07:00
test_settings.py settings: Migrate test settings to modern postgres backend name. 2019-01-23 17:08:24 -08:00
urls.py uploads: Show used upload space in attachments UI. 2019-03-07 20:18:00 -08:00
wsgi.py python: Mark intentionally unused imports with noop statements. 2019-02-22 16:54:47 -08:00