fix: bypass IP restriction for the methods required for our socketio backend

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

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-05-31 13:06:00 +05:30
parent 68c5307fd9
commit 68fd322955
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -421,7 +421,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