o
    ^~#g                     @  sr   d dl mZ 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 dZdS )	    )annotationsN)AuthCredentialsAuthenticationBackendAuthenticationErrorUnauthenticatedUser)HTTPConnection)PlainTextResponseResponse)ASGIAppReceiveScopeSendc                   @  s2   e Zd Z	ddd
dZdddZedddZdS )AuthenticationMiddlewareNappr
   backendr   on_errorGtyping.Callable[[HTTPConnection, AuthenticationError], Response] | NonereturnNonec                 C  s*   || _ || _|d ur|| _d S | j| _d S N)r   r   default_on_errorr   )selfr   r   r    r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/starlette/middleware/authentication.py__init__   s   
z!AuthenticationMiddleware.__init__scoper   receiver   sendr   c              
     s   |d dvr|  |||I d H  d S t|}z| j|I d H }W n3 tyU } z'| ||}|d dkrA|dddI d H  n	||||I d H  W Y d }~d S d }~ww |d u r`t t f}|\|d< |d< |  |||I d H  d S )	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responser   r   r   __call__   s&   z!AuthenticationMiddleware.__call__r%   r   r'   	Exceptionr	   c                 C  s   t t|ddS )Ni  )status_code)r   str)r%   r'   r   r   r   r   2   s   z)AuthenticationMiddleware.default_on_errorr   )r   r
   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r%   r   r'   r*   r   r	   )__name__
__module____qualname__r   r)   staticmethodr   r   r   r   r   r      s    
r   )
__future__r   typingstarlette.authenticationr   r   r   r   starlette.requestsr   starlette.responsesr   r	   starlette.typesr
   r   r   r   r   r   r   r   r   <module>   s    