Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/django/middleware/__pycache__/ |
Upload File : |
o 3�a�5 � @ s* d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m Z ddlmZ ddl mZ ddlmZmZ dd lmZ dd lmZ ddlmZ e�d�Zd ZdZdZdZdZdZdZ de Z!ej"ej# Z$dZ%dd� Z&dd� Z'dd� Z(dd� Z)dd� Z*d d!� Z+d"d#� Z,d$d%� Z-d&d'� Z.G d(d)� d)e�Z/dS )*z� Cross Site Request Forgery Middleware. This module provides a middleware that implements protection against request forgeries from other sites. � N)�urlparse)�settings)�DisallowedHost�ImproperlyConfigured)�get_callable)�patch_vary_headers)�constant_time_compare�get_random_string)�MiddlewareMixin)�is_same_domain)�log_responsezdjango.security.csrfz%Referer checking failed - no Referer.z@Referer checking failed - %s does not match any trusted origins.zCSRF cookie not set.z CSRF token missing or incorrect.z/Referer checking failed - Referer is malformed.zCReferer checking failed - Referer is insecure while host is secure.� � � _csrftokenc C s t tj�S )z/Return the view to be used for CSRF rejections.)r r �CSRF_FAILURE_VIEW� r r �8/usr/lib/python3/dist-packages/django/middleware/csrf.py�_get_failure_view$ s r c C s t ttd�S )N)� allowed_chars)r �CSRF_SECRET_LENGTH�CSRF_ALLOWED_CHARSr r r r �_get_new_csrf_string) s r c sP t � }t� t� fdd�| D �� fdd�|D ��}d�� fdd�|D ��}|| S )z� Given a secret (assumed to be a string of CSRF_ALLOWED_CHARS), generate a token by adding a mask and applying it to the secret. c 3 � � | ]}� � |�V qd S �N��index��.0�x��charsr r � <genexpr>4 � � z&_mask_cipher_secret.<locals>.<genexpr>� c 3 s( � | ]\}}� || t � � V qd S r )�len�r r �yr r r r! 5 s �&