Skip to content

Commit

Permalink
fix: bypass IP restriction for the methods required for our socketio …
Browse files Browse the repository at this point in the history
…backend

Those requests are made from a separate backend, not by the user.

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
(cherry picked from commit 68fd322)
  • Loading branch information
akhilnarang authored and mergify[bot] committed May 31, 2024
1 parent 72a326e commit b8eca5c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frappe/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,18 @@ def clear_cookies():


def validate_ip_address(user):
"""check if IP Address is valid"""
"""
Method to check if the user has IP restrictions enabled, and if so is the IP address they are
connecting from allowlisted.
Certain methods called from our socketio backend need direct access, and so the IP is not
checked for those
"""
if hasattr(frappe.local, "request") and frappe.local.request.path.startswith(
"/api/method/frappe.realtime."
):
return True

from frappe.core.doctype.user.user import get_restricted_ip_list

# Only fetch required fields - for perf
Expand Down

0 comments on commit b8eca5c

Please sign in to comment.