U
    Ÿ·…dÿ  ã                   @   sB   d Z ddlZddlmZ ddlmZ e e¡ZG dd„ deƒZ	dS )	z±
oauthlib.oauth1.rfc5849.endpoints.signature_only
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module is an implementation of the signing logic of OAuth 1.0 RFC 5849.
é    Né   )Úerrorsé   )ÚBaseEndpointc                   @   s   e Zd ZdZddd„ZdS )ÚSignatureOnlyEndpointz>An endpoint only responsible for verifying an oauth signature.ÚGETNc           
   
   C   sH  z|   ||||¡}W n8 tjk
rL } zt d| ¡ W Y ¢dS d}~X Y nX z|  |¡ |  |¡ W n> tjk
r¤ } zt d| ¡ d|f W Y ¢S d}~X Y nX | j |j	|j
|j|¡sÐt d¡ d|fS | j |j	|¡}|sî| jj|_	|  |¡}||jd< ||jd< t||fƒ}	|	s@t d¡ t d	|¡ t d
|¡ |	|fS )a°  Validate a signed OAuth request.

        :param uri: The full URI of the token request.
        :param http_method: A valid HTTP verb, i.e. GET, POST, PUT, HEAD, etc.
        :param body: The request body as a string.
        :param headers: The request headers as a dict.
        :returns: A tuple of 2 elements.
                  1. True if valid, False otherwise.
                  2. An oauthlib.common.Request object.
        z.Exception caught while validating request, %s.)FNNFz.[Failure] verification failed: timestamp/nonceÚclientÚ	signaturez&[Failure] request verification failed.zValid client: %szValid signature: %s)Z_create_requestr   ZOAuth1ErrorÚlogÚinfoZ_check_transport_securityZ_check_mandatory_parametersZrequest_validatorZvalidate_timestamp_and_nonceZ
client_keyÚ	timestampÚnonceÚdebugZvalidate_client_keyZdummy_clientZ_check_signatureZvalidator_logÚall)
ÚselfÚuriZhttp_methodÚbodyÚheadersÚrequestÚerrZvalid_clientZvalid_signatureÚv© r   úT/tmp/pip-unpacked-wheel-h2n314cv/oauthlib/oauth1/rfc5849/endpoints/signature_only.pyÚvalidate_request   sL    ÿ
ÿ   ÿ
	 ÿ




z&SignatureOnlyEndpoint.validate_request)r   NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s
       ÿr   )
r   ÚloggingÚ r   Úbaser   Ú	getLoggerr   r
   r   r   r   r   r   Ú<module>   s
   
