mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Check ip unit test and modify ways to parse IP address
This commit is contained in:
@@ -46,10 +46,10 @@ def requires_no_auth():
|
||||
|
||||
def restrict_ip_sms():
|
||||
ip = ''
|
||||
if request.headers.getlist("X-Forwarded-For"):
|
||||
ip0 = request.headers.getlist("X-Forwarded-For")
|
||||
ip1 = ip0.split(',')
|
||||
ip = ip1[0]
|
||||
if request.headers.get("X-Forwarded-For"):
|
||||
# X-Forwarded-For looks like "203.0.113.195, 70.41.3.18, 150.172.238.178"
|
||||
ip_list = request.headers.get("X-Forwarded-For")
|
||||
ip = ip_list.split(',')[0].strip()
|
||||
|
||||
if ip in current_app.config.get('ALLOW_IP_INBOUND_SMS'):
|
||||
current_app.logger.info("Inbound sms ip addresses {} passed ".format(ip))
|
||||
|
||||
Reference in New Issue
Block a user