
    {h                      Z    d dl Z d dlmZ d dlmZ d dlmZ  G d de      Z G d d      Z	y)	    N)Any) OAuthAuthorizationServerProvider)OAuthClientInformationFullc                       e Zd ZdefdZy)AuthenticationErrormessagec                     || _         y )N)r   )selfr   s     g/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/mcp/server/auth/middleware/client_auth.py__init__zAuthenticationError.__init__	   s	        N)__name__
__module____qualname__strr    r   r   r   r      s     r   r   c                   B    e Zd ZdZdeeeef   fdZdededz  defdZ	y)	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                     || _         y)zx
        Initialize the dependency.

        Args:
            provider: Provider to look up client information
        N)r   )r
   r   s     r   r   zClientAuthenticator.__init__   s     !r   	client_idclient_secretNreturnc                 Z  K   | j                   j                  |       d {   }|st        d      |j                  rh|st        d      |j                  |k7  rt        d      |j                  r5|j                  t        t        j                               k  rt        d      |S 7 w)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   clients       r   authenticatez ClientAuthenticator.authenticate!   s     }}//	::%&9::  )*EFF##}4)*ABB..63R3RUXY]YbYbYdUe3e)*EFF! ;s   B+B)BB+)
r   r   r   __doc__r   r   r   r   r   r    r   r   r   r   r      s>    !!A#sC-!P !C d
 Oi r   r   )
r   typingr   mcp.server.auth.providerr   mcp.shared.authr   	Exceptionr   r   r   r   r   <module>r&      s'      E 6) 
& &r   