def__call__(self,request):# We would like to be able to just check request.resolver_match.app_name. Unfortunately, URL resolving has not taken place yet, so we can't.ifrequest.path=="/prometheus"orrequest.path.startswith("/prometheus/"):remote_addr=request.META["HTTP_X_REAL_IP"]if"HTTP_X_REAL_IP"inrequest.METAelserequest.META.get("REMOTE_ADDR","")is_superuser=request.user.is_authenticatedandrequest.user.is_superuser# If they're not from an IP on the white list and they're not a superuser, deny accessifremote_addrnotinsettings.ALLOWED_METRIC_SCRAPE_IPSandnotis_superuser:returnrender(request,"error/403.html",{"reason":"You are not authorized to view this page."},status=403)returnself.get_response(request)