Skip to content

Commit

Permalink
Merge pull request #21935 from frappe/mergify/bp/version-13-hotfix/pr…
Browse files Browse the repository at this point in the history
…-21929

fix: rate limit for all HTTP methods (backport #21929)
  • Loading branch information
sagarvora committed Aug 21, 2023
2 parents ee1fb91 + 83c9725 commit dd75f6c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions frappe/core/doctype/user/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ def test_reset_password(self):
set_request(path="/random")
frappe.local.cookie_manager = CookieManager()
frappe.local.login_manager = LoginManager()
# used by rate limiter when calling reset_password
frappe.local.request_ip = "127.0.0.69"
frappe.db.set_single_value("System Settings", "password_reset_limit", 6)

frappe.set_user("testpassword@example.com")
test_user = frappe.get_doc("User", "testpassword@example.com")
Expand Down
2 changes: 1 addition & 1 deletion frappe/core/doctype/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def sign_up(email, full_name, redirect_to):


@frappe.whitelist(allow_guest=True)
@rate_limit(limit=get_password_reset_limit, seconds=24 * 60 * 60, methods=["POST"])
@rate_limit(limit=get_password_reset_limit, seconds=24 * 60 * 60)
def reset_password(user):
if user == "Administrator":
return "not allowed"
Expand Down
2 changes: 1 addition & 1 deletion frappe/website/doctype/web_form/web_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def get_web_form_module(doc):


@frappe.whitelist(allow_guest=True)
@rate_limit(key="web_form", limit=5, seconds=60, methods=["POST"])
@rate_limit(key="web_form", limit=5, seconds=60)
def accept(web_form, data, for_payment=False):
"""Save the web form"""
data = frappe._dict(json.loads(data))
Expand Down

0 comments on commit dd75f6c

Please sign in to comment.