Ë
    ÷i¯e/  ã                   ó¦   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d„ Zd	„ Z G d
„ de«      Z G d„ de«      Z G d„ de«      Zy)é    )Úpartial)Úauth)Úload_backend)ÚRemoteUserBackend)ÚImproperlyConfigured)ÚMiddlewareMixin)ÚSimpleLazyObjectc                 óf   — t        | d«      st        j                  | «      | _        | j                  S )NÚ_cached_user)Úhasattrr   Úget_userr   ©Úrequests    úGE:\TRUCKING_PROJECT\Lib\site-packages\django/contrib/auth/middleware.pyr   r      s)   € Ü�7˜NÔ+Ü#Ÿ}™}¨WÓ5ˆÔØ×ÑÐó    c              ƒ   ó‚   K  — t        | d«      s"t        j                  | «      ƒ d {  –—† | _        | j                  S 7 Œ­w)NÚ_acached_user)r   r   Ú	aget_userr   r   s    r   Úauserr      s5   è ø€ Ü�7˜OÔ,Ü&*§n¡n°WÓ&=× =ˆÔØ× Ñ Ð ð !>ús   ‚%?§=¨?c                   ó   — e Zd Zd„ Zy)ÚAuthenticationMiddlewarec                 ó„   ‡— t        ‰d«      st        d«      ‚t        ˆfd„«      ‰_        t	        t
        ‰«      ‰_        y )NÚsessionzñThe Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE setting to insert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'.c                  ó   •— t        ‰ «      S )N)r   r   s   €r   ú<lambda>z:AuthenticationMiddleware.process_request.<locals>.<lambda>!   s   ø€ ´¸Ó0A€ r   )r   r   r	   Úuserr   r   )Úselfr   s    `r   Úprocess_requestz(AuthenticationMiddleware.process_request   s=   ø€ Ü�w 	Ô*Ü&ðMóð ô (Ó(AÓBˆŒÜ¤ wÓ/ˆ�r   N)Ú__name__Ú
__module__Ú__qualname__r   © r   r   r   r      s   „ ó
0r   r   c                   ó*   — e Zd ZdZdZdZd„ Zd„ Zd„ Zy)ÚRemoteUserMiddlewareaý  
    Middleware for utilizing web-server-provided authentication.

    If request.user is not authenticated, then this middleware attempts to
    authenticate the username passed in the ``REMOTE_USER`` request header.
    If authentication is successful, the user is automatically logged in to
    persist the user in the session.

    The header used is configurable and defaults to ``REMOTE_USER``.  Subclass
    this class and change the ``header`` attribute if you need to use a
    different header.
    ÚREMOTE_USERTc                 ó  — t        |d«      st        d«      ‚	 |j                  | j                     }|j                  j                  r?|j                  j                  «       | j                  ||«      k(  ry | j                  |«       t        j                  ||¬«      }|r||_        t        j                  ||«       y y # t        $ r6 | j
                  r'|j                  j                  r| j                  |«       Y y w xY w)Nr   zçThe Django remote user auth middleware requires the authentication middleware to be installed.  Edit your MIDDLEWARE setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the RemoteUserMiddleware class.)Úremote_user)r   r   ÚMETAÚheaderÚKeyErrorÚforce_logout_if_no_headerr   Úis_authenticatedÚ_remove_invalid_userÚget_usernameÚclean_usernamer   ÚauthenticateÚlogin)r   r   Úusernamer   s       r   r   z$RemoteUserMiddleware.process_request9   så   € ä�w Ô'Ü&ð:óð ð	Ø—|‘| D§K¡KÑ0ˆHð �<‰<×(Ò(Ø�|‰|×(Ñ(Ó*¨d×.AÑ.AÀ(ÈGÓ.TÒTØð ×)Ñ)¨'Ô2ô × Ñ  °hÔ?ˆÙð  ˆGŒLÜ�J‰J�w Õ%ð	 øô+ ò 	ð ×-Ò-°'·,±,×2OÒ2OØ×)Ñ)¨'Ô2Ùð	ús   ™B? Â?<C>Ã=C>c                 ó®   — |j                   t        j                     }t        j                  |«      }	 |j	                  |«      }|S # t
        $ r Y |S w xY w)zr
        Allow the backend to clean the username, if the backend defines a
        clean_username method.
        )r   r   ÚBACKEND_SESSION_KEYr   r/   ÚAttributeError)r   r2   r   Úbackend_strÚbackends        r   r/   z#RemoteUserMiddleware.clean_username`   s]   € ð
 —o‘o¤d×&>Ñ&>Ñ?ˆÜ×#Ñ# KÓ0ˆð	Ø×-Ñ-¨hÓ7ˆHð ˆøô ò 	ØØˆð	ús   ´A Á	AÁAc                 ó   — 	 t        |j                  j                  t        j                  d«      «      }t        |t        «      rt        j                  |«       yy# t        $ r t        j                  |«       Y yw xY w)z 
        Remove the current authenticated user in the request which is invalid
        but only if the user is authenticated via the RemoteUserBackend.
        Ú N)	r   r   Úgetr   r4   Ú
isinstancer   ÚlogoutÚImportError)r   r   Ústored_backends      r   r-   z)RemoteUserMiddleware._remove_invalid_userm   sf   € ð
		%Ü)Ø—‘×#Ñ#¤D×$<Ñ$<¸bÓAóˆNô ˜.Ô*;Ô<Ü—‘˜GÕ$ð =øô	 ò 	!ä�K‰K˜Ö ð	!ús   ‚3A ÁA=Á<A=N)	r   r    r!   Ú__doc__r)   r+   r   r/   r-   r"   r   r   r$   r$   %   s$   „ ñð  €FØ $Ðò%&òNó%r   r$   c                   ó   — e Zd ZdZdZy)ÚPersistentRemoteUserMiddlewarea£  
    Middleware for web-server provided authentication on logon pages.

    Like RemoteUserMiddleware but keeps the user authenticated even if
    the header (``REMOTE_USER``) is not found in the request. Useful
    for setups when the external authentication via ``REMOTE_USER``
    is only expected to happen on some "logon" URL and the rest of
    the application wants to use Django's authentication mechanism.
    FN)r   r    r!   r?   r+   r"   r   r   rA   rA   ~   s   „ ñð !&Ñr   rA   N)Ú	functoolsr   Údjango.contribr   Údjango.contrib.authr   Údjango.contrib.auth.backendsr   Údjango.core.exceptionsr   Údjango.utils.deprecationr   Údjango.utils.functionalr	   r   r   r   r$   rA   r"   r   r   ú<module>rI      sL   ðÝ å Ý ,Ý :Ý 7Ý 4Ý 4ò ò!ô0˜ô 0ôV%˜?ô V%ôr&Ð%9õ &r   