cfdZddlZddlmZddlmZejeZGddeZ dS) z oauthlib.oauth1.rfc5849.endpoints.resource ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of the resource protection provider logic of OAuth 1.0 RFC 5849. N)errors) BaseEndpointceZdZdZ ddZdS)ResourceEndpointa!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) GETNc |||||}n#tj$rYdSwxYw ||||n#tj$rd|fcYSwxYw|jsd|fS|j|jsd|fS|j|j |j |j ||jsd|fS|j |j |}|s|jj |_ |j|j |j|}|s|jj|_|j|j |j||j|} ||} ||jd<||jd<| |jd<| |jd<t)||| | f} | st*d t*d |t*d |t*d | t*d | | |fS)aCreate 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)urirealmsclientresource_ownerrealm signaturez&[Failure] request verification failed.zValid client: %szValid token: %szValid realm: %szValid signature: %s)_create_requestr OAuth1Error_check_transport_security_check_mandatory_parametersresource_owner_keyrequest_validatorcheck_access_tokenvalidate_timestamp_and_nonce client_key timestampnoncevalidate_client_key dummy_clientvalidate_access_tokendummy_access_tokenvalidate_realmsr _check_signature validator_logallloginfo) selfr http_methodbodyheadersr request valid_clientvalid_resource_owner valid_realmvalid_signaturevs L/usr/lib/python3/dist-packages/oauthlib/oauth1/rfc5849/endpoints/resource.py#validate_protected_resource_requestz4ResourceEndpoint.validate_protected_resource_request5s **3 T7KKGG!   ;;  "  * *7 3 3 3  , ,W 5 5 5 5! " " "'> ! ! ! ") "'> !%88*,, "'> !%BB"G$5w}g$7C99 "'> !-AA  ))  E!%!7!DG  $5KK   :G E E# S)-)?)RG &0,< > > HH' 6 6 6 HH&(< = = = HH& 4 4 4 HH*O < < <'zs..*AA32A3)r NNN)__name__ __module__ __qualname____doc__r2r1rrsC  DDILPnnnnnnr8r) r6loggingrbaser getLoggerr3r%rr7r8r1r=sg!!RRRRR|RRRRRr8