code: def process_request(self, request):
          
          # Section adjusted to restrict login to ?edit
          # (sing cms-toolbar-login)into DjangoCMS login.
          restricted_request_uri = request.path.startswith(
              reverse('admin:index') or "cms-toolbar-login" in request.build_absolute_uri()
          )
          if restricted_request_uri and request.method == 'POST':
  
              # AllowedIP table emty means access is always granted
              if AllowedIP.objects.count() > 0:
  
                  # If there are wildcard IPs access is always granted
                  if AllowedIP.objects.filter(ip_address="*").count() == 0:
  
                      request_ip = get_ip_address_from_request(request)
  
                      # If the request_ip is in the AllowedIP the access
                      # is granted
                      if AllowedIP.objects.filter(ip_address=request_ip).count() == 0:
  
                          # We check regular expressions defining ranges
                          # of IPs. If any range contains the request_ip
                          # the access is granted
                          for regex_ip_range in AllowedIP.objects.filter(ip_address__endswith="*"):
                              if re.match(regex_ip_range.ip_address.replace("*", ".*"), request_ip):
                                  return None
                          return HttpResponseForbidden("Access to admin is denied.")
docs: Check if the request is made form an allowed IP