o a"@s\dZddlZddlZddlmZmZmZmZmZm Z m Z e e Z GdddZddZdS) z oauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. N)FatalClientErrorInvalidClientErrorInvalidRequestError OAuth2Error ServerErrorTemporarilyUnavailableErrorUnsupportedTokenTypeErrorc@seZdZddZeddZejddZeddZejddZed d Zejd d Zd d Z ddZ ddZ ddZ ddZ dS) BaseEndpointcCsd|_d|_d|_dS)NTF) _available _catch_errors_valid_request_methodsselfrH/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/endpoints/base.py__init__s zBaseEndpoint.__init__cC|jSNr rrrrvalid_request_methodsz"BaseEndpoint.valid_request_methodscCs |dur dd|D}||_dS)NcSsg|]}|qSr)upper).0xrrr !sz6BaseEndpoint.valid_request_methods..r)rrrrrrs cCrrr rrrr available%rzBaseEndpoint.availablecC ||_dSrr)rrrrrr) cCrrr rrrr catch_errors-rzBaseEndpoint.catch_errorscCrrr )rr!rrrr!1rcCs|js t|dddS)zRaise error on missing token.zMissing token parameter.request descriptionN)tokenrrr#rrr_raise_on_missing_token5s z$BaseEndpoint._raise_on_missing_tokencCs\|j|r|j|std|t|ddS|j|j|s,td|t|ddS)z&Raise on failed client authentication.z!Client authentication failed, %r.r#N)request_validatorclient_authentication_requiredauthenticate_clientlogdebugrauthenticate_client_id client_idr&rrr_raise_on_invalid_client:s      z%BaseEndpoint._raise_on_invalid_clientcCs4|jr|j|jvr|j|jvrt|ddSdSdS)zRaise on unsupported tokens.r(N)token_type_hintvalid_token_typessupported_token_typesr r&rrr_raise_on_unsupported_tokenDs   z(BaseEndpoint._raise_on_unsupported_tokencCs<|jdur td|j|jvrt|d|jddS)Nz0Configure "valid_request_methods" property firstzUnsupported request method %sr")r ValueError http_methodrrr&rrr_raise_on_bad_methodKs  z!BaseEndpoint._raise_on_bad_methodcCs0|jdkr|jp d}|rt|dddSdS)z/Raise if invalid POST request received POSTz$URL query parameters are not allowedr"N)r6r uri_queryr)rr# query_paramsrrr_raise_on_bad_post_requestRs z'BaseEndpoint._raise_on_bad_post_requestN)__name__ __module__ __qualname__rpropertyrsetterrr!r'r0r4r7r<rrrrr s&        r cstfdd}|S)Nc s|jst}td|i|jdfS|jrTz ||g|Ri|WSty+ty2tyS}zt }t d|i|jdfWYd}~Sd}~ww||g|Ri|S)Nz*Endpoint unavailable, ignoring request %s.iz.Exception caught while processing request, %s.i) rrr,infojsonr!rr Exceptionrwarning)endpointuriargskwargseerrorfrrwrapper\s(   z0catch_errors_and_unavailability..wrapper) functoolswraps)rMrNrrLrcatch_errors_and_unavailability[srQ)__doc__rOloggingerrorsrrrrrrr getLoggerr=r,r rQrrrrs$  H