Exemple #1
0
 def authorize(request, *args, **kwargs):
     user_ip = get_client_ip(request)
     if settings.LOCKSS_DEBUG_IPS:
         logger.warn("CACHED MIRRORS: {}".format(Mirror.get_cached_mirrors()))
         logger.warn("CLIENT IP: {}".format(user_ip))
         logger.warn("request.META: {}\n".format(request.META))
     for mirror in Mirror.get_cached_mirrors():
         if user_ip == mirror['ip']:
             return view_func(request, *args, **kwargs)
     return HttpResponseForbidden()
Exemple #2
0
 def authorize(request, *args, **kwargs):
     user_ip = get_client_ip(request)
     if settings.LOCKSS_DEBUG_IPS:
         logger.warn("CACHED MIRRORS: {}".format(
             Mirror.get_cached_mirrors()))
         logger.warn("CLIENT IP: {}".format(user_ip))
         logger.warn("request.META: {}\n".format(request.META))
     for mirror in Mirror.get_cached_mirrors():
         if user_ip == mirror['ip']:
             return view_func(request, *args, **kwargs)
     return HttpResponseForbidden()
Exemple #3
0
 def test_get_client_ip(self):
     request = self.factory.get('/some/route', REMOTE_ADDR="1.2.3.4")
     self.assertEqual(get_client_ip(request), "1.2.3.4")
Exemple #4
0
def client_ip(request):
    return HttpResponse(get_client_ip(request))