
    Ch                      Z    S SK r S SKJr  S SKJr  S SKJr   " S S\5      r " S S5      r	g)	    N)Any) OAuthAuthorizationServerProvider)OAuthClientInformationFullc                   "    \ rS rSrS\4S jrSrg)AuthenticationError   messagec                     Xl         g )Nr	   )selfr	   s     `/home/james-whalen/.local/lib/python3.13/site-packages/mcp/server/auth/middleware/client_auth.py__init__AuthenticationError.__init__	   s        r   N)__name__
__module____qualname____firstlineno__strr   __static_attributes__ r   r   r   r      s     r   r   c                   N    \ rS rSrSrS\\\\4   4S jrS\S\S-  S\	4S	 jr
S
rg)ClientAuthenticator   aw  
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                     Xl         g)zX
Initialize the dependency.

Args:
    provider: Provider to look up client information
Nr   )r   r   s     r   r   ClientAuthenticator.__init__   s	     !r   	client_idclient_secretNreturnc                   #    U R                   R                  U5      I S h  vN nU(       d  [        S5      eUR                  (       au  U(       d  [        S5      eUR                  U:w  a  [        S5      eUR                  (       a7  UR                  [        [        R                  " 5       5      :  a  [        S5      eU$  N7f)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   authenticate ClientAuthenticator.authenticate!   s     }}//	::%&9::  )*EFF##}4)*ABB..63R3RUXY]YbYbYdUe3e)*EFF! ;s   CC BCr   )r   r   r   r   __doc__r   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   