U
    5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|st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-g6yohpa1/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
   
