
    vh                    |    d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZmZ d dlmZmZmZmZ  G d d      Zy	)
    )annotations)Callable)AuthCredentialsAuthenticationBackendAuthenticationErrorUnauthenticatedUser)HTTPConnection)PlainTextResponseResponse)ASGIAppReceiveScopeSendc                  @    e Zd Z	 d	 	 	 	 	 	 	 ddZddZedd       Zy)	AuthenticationMiddlewareNc                V    || _         || _        ||| _        y | j                  | _        y N)appbackenddefault_on_erroron_error)selfr   r   r   s       [/var/www/html/luna/venv/lib/python3.12/site-packages/starlette/middleware/authentication.py__init__z!AuthenticationMiddleware.__init__   s1      ,H 	262G2G 	    c                  K   |d   dvr| j                  |||       d {    y t        |      }	 | j                  j                  |       d {   }|t               t               f}|\  |d<   |d<   | j                  |||       d {    y 7 q7 C# t        $ rL}| j                  ||      }|d   dk(  r |ddd       d {  7   n ||||       d {  7   Y d }~y d }~ww xY w7 aw)	Ntype)http	websocketr   zwebsocket.closei  )r   codeauthuser)r   r	   r   authenticater   r   r   r   )r   scopereceivesendconnauth_resultexcresponses           r   __call__z!AuthenticationMiddleware.__call__   s     = 55((5'4000e$	 $ 9 9$ ??K )+-@-BBK'2$fuV}hhugt,,,# 1
 @" 	}}T3/HV}+$5tDEEEugt444	 	-sn   C0BC0B BB 7C0C.C0B 	C+(C&C
C&CC&!C0&C++C0c                .    t        t        |      d      S )Ni  )status_code)r
   str)r'   r)   s     r   r   z)AuthenticationMiddleware.default_on_error2   s     Ss;;r   r   )r   r   r   r   r   z@Callable[[HTTPConnection, AuthenticationError], Response] | NonereturnNone)r$   r   r%   r   r&   r   r/   r0   )r'   r	   r)   	Exceptionr/   r   )__name__
__module____qualname__r   r+   staticmethodr    r   r   r   r      sN    
 VZ	



 '

 S	


 


-* < <r   r   N)
__future__r   typingr   starlette.authenticationr   r   r   r   starlette.requestsr	   starlette.responsesr
   r   starlette.typesr   r   r   r   r   r6   r   r   <module>r=      s-    "   . ; 9 9$< $<r   