a
    Lcòf  ã                   @   s�   d dl mZ d dlmZmZ d dlmZ eeƒZde_de_	G dd„ deƒZ
ee
ƒZde_d	e_	G d
d„ deƒZeeƒZde_de_	dd„ ZdS )é    )Úwraps)ÚCsrfViewMiddlewareÚ	get_token)Údecorator_from_middlewareÚcsrf_protectzË
This decorator adds CSRF protection in exactly the same way as
CsrfViewMiddleware, but it can be used on a per view basis.  Using both, or
using the decorator multiple times, is harmless and efficient.
c                   @   s   e Zd Zdd„ ZdS )Ú_EnsureCsrfTokenc                 C   s   d S ©N© ©ÚselfÚrequestÚreasonr	   r	   úY/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/django/views/decorators/csrf.pyÚ_reject   s    z_EnsureCsrfToken._rejectN)Ú__name__Ú
__module__Ú__qualname__r   r	   r	   r	   r   r      s   r   Úrequires_csrf_tokenz•
Use this decorator on views that need a correct csrf_token available to
RequestContext, but without the CSRF protection that csrf_protect
enforces.
c                       s$   e Zd Zdd„ Z‡ fdd„Z‡  ZS )Ú_EnsureCsrfCookiec                 C   s   d S r   r	   r
   r	   r	   r   r      s    z_EnsureCsrfCookie._rejectc                    s   t ƒ  ||||¡}t|ƒ |S r   )ÚsuperÚprocess_viewr   )r   r   ÚcallbackÚcallback_argsÚcallback_kwargsÚretval©Ú	__class__r	   r   r   "   s    z_EnsureCsrfCookie.process_view)r   r   r   r   r   Ú__classcell__r	   r	   r   r   r      s   r   Úensure_csrf_cookiez•
Use this decorator to ensure that a view sets a CSRF cookie, whether or not it
uses the csrf_token template tag, or the CsrfViewMiddleware is used.
c                    s   t ˆ ƒ‡ fdd„ƒ}d|_|S )zCMark a view function as being exempt from the CSRF view protection.c                     s   ˆ | i |¤ŽS r   r	   )ÚargsÚkwargs©Ú	view_funcr	   r   Úwrapper_view6   s    z!csrf_exempt.<locals>.wrapper_viewT)r   Úcsrf_exempt)r"   r#   r	   r!   r   r$   1   s    r$   N)Ú	functoolsr   Zdjango.middleware.csrfr   r   Zdjango.utils.decoratorsr   r   r   Ú__doc__r   r   r   r   r$   r	   r	   r	   r   Ú<module>   s   