Commit a7df7cdd authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files


parent de03b5db
Pipeline #8071 failed with stage
in 23 seconds
from ipaddress import ip_address, ip_network
from pprint import pprint
from django.conf import settings
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
......@@ -8,6 +9,7 @@ from rest_framework import permissions
def ip_laas(request: HttpRequest) -> bool:
forwarded_for = ip_address(request.META.get('HTTP_X_FORWARDED_FOR'))
for net in settings.LAAS_NETWORKS:
print(forwarded_for, 'in', ip_network(net))
return any(forwarded_for in ip_network(net) for net in settings.LAAS_NETWORKS)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment