Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta limits to track and act on repeated rate limit breaches #418

Merged
merged 13 commits into from
Aug 31, 2023
Prev Previous commit
Next Next commit
Ensure on breach callbacks from config are respected
  • Loading branch information
alisaifee committed Aug 30, 2023
commit b710a3c99fb18dcb7b6128aebc519d8ec76467c9
8 changes: 7 additions & 1 deletion flask_limiter/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ def init_app(self, app: flask.Flask) -> None:
shared=True,
)
]

self._on_breach = self._on_breach or config.get(ConfigVars.ON_BREACH, None)
self._on_meta_breach = self._on_meta_breach or config.get(
ConfigVars.ON_META_BREACH, None
)

self.__configure_fallbacks(app, self._strategy)

if self not in app.extensions.setdefault("limiter", set()):
Expand Down Expand Up @@ -1042,7 +1048,7 @@ def __evaluate_limits(self, endpoint: str, limits: List[Limit]) -> None:
except Exception as err: # noqa
if self._swallow_errors:
self.logger.exception(
"on_breach callback failed with error %s", err
"on_meta_breach callback failed with error %s", err
)
else:
raise err
Expand Down
Loading