o
    i                      @   sN   d dl Z d dlmZ d dlmZ d dlmZ G dd deZG dd dZ	dS )	    N)Any) OAuthAuthorizationServerProvider)OAuthClientInformationFullc                   @   s   e Zd ZdefddZdS )AuthenticationErrormessagec                 C   s
   || _ d S )N)r   )selfr    r   l/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/mcp/server/auth/middleware/client_auth.py__init__	   s   
zAuthenticationError.__init__N)__name__
__module____qualname__strr
   r   r   r   r	   r      s    r   c                   @   sB   e Zd ZdZdeeeef fddZdededB defd	d
Z	dS )ClientAuthenticatora  
    ClientAuthenticator is a callable which validates requests from a client
    application, used to verify /token calls.
    If, during registration, the client requested to be issued a secret, the
    authenticator asserts that /token calls must be authenticated with
    that same token.
    NOTE: clients can opt for no authentication during registration, in which case this
    logic is skipped.
    providerc                 C   s
   || _ dS )zx
        Initialize the dependency.

        Args:
            provider: Provider to look up client information
        N)r   )r   r   r   r   r	   r
      s   
zClientAuthenticator.__init__	client_idclient_secretNreturnc                    sh   | j |I d H }|std|jr2|std|j|kr"td|jr2|jtt k r2td|S )NzInvalid client_idzClient secret is requiredzInvalid client_secretzClient secret has expired)r   
get_clientr   r   client_secret_expires_atinttime)r   r   r   clientr   r   r	   authenticate!   s   
z ClientAuthenticator.authenticate)
r   r   r   __doc__r   r   r
   r   r   r   r   r   r   r	   r      s    
	r   )
r   typingr   mcp.server.auth.providerr   mcp.shared.authr   	Exceptionr   r   r   r   r   r	   <module>   s    