
                         r    S r SSKJrJr  SSKrSSKJr  SSKJr  \R                  " \
5      r " S S	\5      rg)
zoauthlib.oauth1.rfc5849.endpoints.resource ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module is an implementation of the resource protection provider logic of
OAuth 1.0 RFC 5849.
    )absolute_importunicode_literalsN   )errors   )BaseEndpointc                   *    \ rS rSrSr    SS jrSrg)ResourceEndpoint   a  An endpoint responsible for protecting resources.

Typical use is to instantiate with a request validator and invoke the
``validate_protected_resource_request`` in a decorator around a view
function. If the request is valid, invoke and return the response of the
view. If invalid create and return an error response directly from the
decorator.

See :doc:`/oauth1/validator` for details on which validator methods to
implement
for this endpoint.

An example decorator::

    from functools import wraps
    from your_validator import your_validator
    from oauthlib.oauth1 import ResourceEndpoint
    endpoint = ResourceEndpoint(your_validator)

    def require_oauth(realms=None):
        def decorator(f):
            @wraps(f)
            def wrapper(request, *args, **kwargs):
                v, r = provider.validate_protected_resource_request(
                        request.url,
                        http_method=request.method,
                        body=request.data,
                        headers=request.headers,
                        realms=realms or [])
                if v:
                    return f(*args, **kwargs)
                else:
                    return abort(403)
Nc                 F    U R                  XX45      n U R                  U5        U R	                  U5        UR
                  (       d  SU4$ U R                  R                  UR
                  5      (       d  SU4$ U R                  R                  UR                  UR                  UR                  UUR
                  S9(       d  SU4$ U R                  R                  UR                  U5      nU(       d  U R                  R                  Ul	        U R                  R                  UR                  UR
                  U5      nU(       d  U R                  R                  Ul        U R                  R!                  UR                  UR
                  UUR"                  US9n	U R%                  U5      n
XvR&                  S'   XR&                  S'   XR&                  S'   XR&                  S'   [)        XxX45      nU(       dm  [*        R-                  S	5        [*        R-                  S
U5        [*        R-                  SU5        [*        R-                  SU	5        [*        R-                  SU
5        X4$ ! [        R                   a     gf = f! [        R                   a    SU4s $ f = f)aD  Create a request token response, with a new request token if valid.

: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.
:param realms: A list of realms the resource is protected under.
               This will be supplied to the ``validate_realms``
               method of the request validator.
:returns: A tuple of 2 elements.
          1. True if valid, False otherwise.
          2. An oauthlib.common.Request object.
)FNF)access_token)urirealmsclientresource_ownerrealm	signaturez&[Failure] request verification failed.zValid client: %szValid token: %szValid realm: %szValid signature: %s)_create_requestr   OAuth1Error_check_transport_security_check_mandatory_parametersresource_owner_keyrequest_validatorcheck_access_tokenvalidate_timestamp_and_nonce
client_key	timestampnoncevalidate_client_keydummy_clientvalidate_access_tokendummy_access_tokenvalidate_realmsr   _check_signaturevalidator_logallloginfo)selfr   http_methodbodyheadersr   requestvalid_clientvalid_resource_ownervalid_realmvalid_signaturevs               =lib/third_party/oauthlib/oauth1/rfc5849/endpoints/resource.py#validate_protected_resource_request4ResourceEndpoint.validate_protected_resource_request5   sm   &$$StEg
$$W-
&&w/ %%G^!!44""$ $G^!!>>// ? 1 G^ ))==G%L11>>g  11GGG66A#'#9#9#L#Lg 0 ((88""KK 9 K ++G4O '3(#.B*+%0'")8+& 	\NOA	hh78	hh!<0	hh "67	hh +.	hh$o6:E    G^s"   I+ "J +JJJ J  )GETNNN)__name__
__module____qualname____firstlineno____doc__r4   __static_attributes__r6       r3   r
   r
      s    !J 7</32615wr>   r
   )r<   
__future__r   r   logging r   baser   	getLoggerr8   r'   r
   r6   r>   r3   <module>rD      s6   
 9   ![| [r>   