""" Cross Site Request Forgery Middleware. This module provides a middleware that implements protection against request forgeries from other sites. """ import itertools import re import random from django.conf import settings from django.core.urlresolvers import get_callable from django.utils.cache import patch_vary_headers from django.utils.hashcompat import md5_constructor from django.utils.log import getLogger from django.utils.safestring import mark_safe from django.utils.crypto import constant_time_compare _POST_FORM_RE = \ re.compile(r'(