
    df                     l    d dl 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)    N)AuthCredentialsAuthenticationBackendAuthenticationErrorUnauthenticatedUser)HTTPConnection)PlainTextResponseResponse)ASGIAppReceiveScopeSendc            
           e Zd Z	 ddededej                  ej                  ee	ge
f      ddfdZdeded	eddfd
Zededede
fd       Zy)AuthenticationMiddlewareNappbackendon_errorreturnc                 V    || _         || _        ||| _        y | j                  | _        y N)r   r   default_on_errorr   )selfr   r   r   s       \/home/api-vastappli/venv/lib/python3.12/site-packages/starlette/middleware/authentication.py__init__z!AuthenticationMiddleware.__init__   s3      "-X 	373H3H 	    scopereceivesendc                   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   r   r   r   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r&   r(   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   )__name__
__module____qualname__r
   r   typingOptionalCallabler   r   r	   r   r   r   r   r*   staticmethod	Exceptionr    r   r   r   r      s     JJ 'J //OO^-@A8KL
	J 
J-E -G -4 -D -* <~ <I <( < <r   r   )r1   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   