o
    L)jR                     @  s  d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZ e	dZd)ddZ		d*d+ddZG dd deZG dd  d ZG d!d" d"ZG d#d$ d$ZG d%d& d&eZG d'd( d(eZ dS ),    )annotationsN)CallableSequence)Any	ParamSpec)	urlencode)is_async_callable)HTTPException)HTTPConnectionRequest)RedirectResponse)	WebSocket_Pconnr
   scopesSequence[str]returnboolc                 C  s    |D ]}|| j jvr dS qdS )NFT)authr   )r   r   scope r   }/var/www/html/finance-dev.cargoinsureonline.com/_shared/backend-venv/lib/python3.10/site-packages/starlette/authentication.pyhas_required_scope   s
   r     str | Sequence[str]status_codeintredirect
str | None0Callable[[Callable[_P, Any]], Callable[_P, Any]]c                   s.   t | tr| gnt| d fdd}|S )NfuncCallable[_P, Any]r   c                   s   t  }t|j D ]\}|jdks|jdkr|j} n	qtd  d|dkr<t d fdd}|S t	 rRt d fdd}|S t d fdd}|S )Nrequest	websocketz2No "request" or "websocket" argument on function ""args_P.argskwargs	_P.kwargsr   Nonec                    sv   | dt| k r|  nd }t|ts!J dt|j dt|s/| I d H  d S  | i |I d H  d S )Nr#   zKParameter with name 'websocket' is required to be of type 'WebSocket' not '')getlen
isinstancer   type__name__r   close)r%   r'   r#   )r    idxscopes_listr   r   websocket_wrapper-   s    
z6requires.<locals>.decorator.<locals>.websocket_wrapperr   c                    s   | dt| k r|  nd }t|ts!J dt|j dt|sHd urCtdt|j	i}|
 d| }t|ddS td | i |I d H S 	Nr"   zGParameter with name 'request' is required to be of type 'Request' not 'r*   next?i/  )urlr   )r   r+   r,   r-   r   r.   r/   r   r   strr7   url_forr   r	   r%   r'   r"   orig_request_qparamnext_urlr    r1   r   r2   r   r   r   async_wrapper>   s    

z2requires.<locals>.decorator.<locals>.async_wrapperc                    s   | dt| k r|  nd }t|ts J dt|j dt|sGd urBtdt|j	i}|
 d| }t|ddS td | i |S r4   r8   r;   r>   r   r   sync_wrapperQ   s    

z1requires.<locals>.decorator.<locals>.sync_wrapper)r%   r&   r'   r(   r   r)   )r%   r&   r'   r(   r   r   )
inspect	signature	enumerate
parametersvaluesname	Exception	functoolswrapsr   )r    sig	parametertype_r3   r?   r@   r   r2   r   )r    r1   r   	decorator    s$   
zrequires.<locals>.decorator)r    r!   r   r!   )r-   r9   list)r   r   r   rN   r   rM   r   requires   s   BrP   c                   @  s   e Zd ZdS )AuthenticationErrorN)r/   
__module____qualname__r   r   r   r   rQ   e   s    rQ   c                   @  s   e Zd ZdddZdS )	AuthenticationBackendr   r
   r   'tuple[AuthCredentials, BaseUser] | Nonec                   s   t  NNotImplementedError)selfr   r   r   r   authenticatej   s   z"AuthenticationBackend.authenticateN)r   r
   r   rU   )r/   rR   rS   rZ   r   r   r   r   rT   i   s    rT   c                   @  s   e Zd ZddddZdS )AuthCredentialsNr   Sequence[str] | Nonec                 C  s    |d u r	g | _d S t || _d S rV   )rO   r   )rY   r   r   r   r   __init__o   s    zAuthCredentials.__init__rV   )r   r\   )r/   rR   rS   r]   r   r   r   r   r[   n   s    r[   c                   @  s6   e Zd ZedddZedddZeddd	Zd
S )BaseUserr   r   c                 C     t  rV   rW   rY   r   r   r   is_authenticatedt      zBaseUser.is_authenticatedr9   c                 C  r_   rV   rW   r`   r   r   r   display_namex   rb   zBaseUser.display_namec                 C  r_   rV   rW   r`   r   r   r   identity|   rb   zBaseUser.identityNr   r   r   r9   )r/   rR   rS   propertyra   rc   rd   r   r   r   r   r^   s   s    r^   c                   @  s2   e Zd ZdddZeddd	Zedd
dZdS )
SimpleUserusernamer9   r   r)   c                 C  s
   || _ d S rV   ri   )rY   ri   r   r   r   r]      s   
zSimpleUser.__init__r   c                 C     dS )NTr   r`   r   r   r   ra         zSimpleUser.is_authenticatedc                 C  s   | j S rV   rj   r`   r   r   r   rc      rb   zSimpleUser.display_nameN)ri   r9   r   r)   re   rf   )r/   rR   rS   r]   rg   ra   rc   r   r   r   r   rh      s    
rh   c                   @  s(   e Zd Zed	ddZed
ddZdS )UnauthenticatedUserr   r   c                 C  rk   )NFr   r`   r   r   r   ra      rl   z$UnauthenticatedUser.is_authenticatedr9   c                 C  rk   )N r   r`   r   r   r   rc      rl   z UnauthenticatedUser.display_nameNre   rf   )r/   rR   rS   rg   ra   rc   r   r   r   r   rm      s
    rm   )r   r
   r   r   r   r   )r   N)r   r   r   r   r   r   r   r   )!
__future__r   rH   rA   collections.abcr   r   typingr   r   urllib.parser   starlette._utilsr   starlette.exceptionsr	   starlette.requestsr
   r   starlette.responsesr   starlette.websocketsr   r   r   rP   rG   rQ   rT   r[   r^   rh   rm   r   r   r   r   <module>   s,    
	L