File "common.cpython-36.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/usr/lib/python3.6/site-packages/oauthlib/__pycache__/common.cpython-36.pyc
File size: 13.21 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

3

,[q9@s@dZddlmZmZddlZddlZddlZddlZddlZddl	Z	yddl
mZddl
mZWn,e
k
rddlmZddlmZYnXy(ddlmZddlmZdd	lmZWn8e
k
rddlmZddlmZdd	lmZYnXyddlZWn e
k
rddljZYnXd
ZdZejdejZejd
ZdZ ej!dZ"ej#ddkZ$e$rje%Z&e'Z(ne)Z&e%Z(d<ddZddZddZddZ*ddZ+e,e e,dBZ-ddZ.dd Z/d!d"Z0d#d$Z1d%efd&d'Z2d(d)Z3d*d+Z4d%efd,d-Z5d.d/Z6d=d1d2Z7d3d4Z8d>d6d7Z9Gd8d9d9e:Z;Gd:d;d;e<Z=dS)?z|
oauthlib.common
~~~~~~~~~~~~~~

This module provides data structures and utilities common
to all implementations of OAuth.
)absolute_importunicode_literalsN)randbits)SystemRandom)getrandbits)quote)unquote)	urlencodeZ>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789z_ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}z&([^&;]*(?:password|token)[^=]*=)[^&;]+z&%[^0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]zAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-Zoauthlib/cCs:t|tr|jdn|}t||}t|tr6|jd}|S)Nzutf-8)
isinstanceunicode_typeencode_quote
bytes_typedecode)sZsafer/usr/lib/python3.6/common.pyr@s



rcCs t|}t|tr|jd}|S)Nzutf-8)_unquoterrr)rrrrrJs

rcCs,t|}t|}t|tr|S|jdSdS)Nzutf-8)encode_params_utf8
_urlencoderr
r)paramsZutf8_params
urlencodedrrrr	Ts

r	cCsPg}xF|D]>\}}|jt|tr*|jdn|t|tr@|jdn|fq
W|S)ziEnsures that all parameters in a list of 2-element tuples are encoded to
    bytestrings using UTF-8
    zutf-8)appendrr
r)rZencodedkvrrrr]s rcCsPg}xF|D]>\}}|jt|tr*|jdn|t|tr@|jdn|fq
W|S)zfEnsures that all parameters in a list of 2-element tuples are decoded to
    unicode using UTF-8.
    zutf-8)rrrr)rZdecodedrrrrrdecode_params_utf8is rz=&;:%+~,*@!()/?cCst|r.t|tkr.d}t|t|t|ftj|r@tdtrZt|trZ|jdn|}t	j
|dd}t|S)aDecode a query string in x-www-form-urlencoded format into a sequence
    of two-element tuples.

    Unlike urlparse.parse_qsl(..., strict_parsing=True) urldecode will enforce
    correct formatting of the query string by validation. If validation fails
    a ValueError will be raised. urllib.parse_qsl will only raise errors if
    any of name-value pairs omits the equals sign.
    zError trying to decode a non urlencoded string. Found invalid characters: %s in the string: '%s'. Please ensure the request/response body is x-www-form-urlencoded.z%Invalid hex encoding in query string.zutf-8T)keep_blank_values)setr
ValueErrorINVALID_HEX_PATTERNsearchPY3rr
rurlparse	parse_qslr)queryerrorrrrr	urldecodexs

r(cCst|tst|tr<yt|}Wqtk
r8d}YqXnnt|dryt|Wn.tk
rjd}Yqtk
rd}YqXtt|tr|j	n|}t
|}nd}|S)a*Extract parameters and return them as a list of 2-tuples.

    Will successfully extract parameters from urlencoded query strings,
    dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
    empty list of parameters. Any other input will result in a return
    value of None.
    N__iter__)rrr
r(r hasattrdict	TypeErrorlistitemsr)rawrrrrextract_paramss 


r0cCstttdtS)aGenerate pseudorandom nonce that is unlikely to repeat.

    Per `section 3.3`_ of the OAuth 1 RFC 5849 spec.
    Per `section 3.2.1`_ of the MAC Access Authentication spec.

    A random 64-bit number is appended to the epoch timestamp for both
    randomness and to decrease the likelihood of collisions.

    .. _`section 3.2.1`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3
    @)r
rgenerate_timestamprrrrgenerate_noncesr3cCstttjS)aDGet seconds since epoch (UTC).

    Per `section 3.3`_ of the OAuth 1 RFC 5849 spec.
    Per `section 3.2.1`_ of the MAC Access Authentication spec.

    .. _`section 3.2.1`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-3.2.1
    .. _`section 3.3`: https://tools.ietf.org/html/rfc5849#section-3.3
    )r
inttimerrrrr2s	r2cs$tdjfddt|DS)aXGenerates a non-guessable OAuth token

    OAuth (1 and 2) does not specify the format of tokens except that they
    should be strings of random characters. Tokens should not be guessable
    and entropy when generating the random characters is important. Which is
    why SystemRandom is used instead of the default random.choice method.
    c3s|]}jVqdS)N)Zchoice).0x)charsrandrr	<genexpr>sz!generate_token.<locals>.<genexpr>)rjoinrange)lengthr:r)r:r;rgenerate_tokensr@cCsTddl}tjj}|j|tj|jdd}|j|j|j||d}t	|d}|S)Nr)Zseconds)scopeZexpRS256zUTF-8)
jwtdatetimeZutcnowrAZ	timedeltaZ
expires_inupdateclaimsr
to_unicode)Zprivate_pemZrequestrCZnowrFtokenrrrgenerate_signed_tokens

rIcCsddl}|j||dgdS)NrrB)Z
algorithms)rCr)Z
public_pemrHrCrrrverify_signed_tokensrJcCs
t||S)zGenerates an OAuth client_id

    OAuth 2 specify the format of client_id in
    https://tools.ietf.org/html/rfc6749#appendix-A.
    )r@)r?r:rrrgenerate_client_idsrKcCs2t|tr|j}tj|dd}|j|t|S)z)Extend a query with a list of two-tuples.T)r)rr+r.r$r%extendr	)r&rZqueryparamsrrradd_params_to_qss


rMFc	CsFtj|\}}}}}}|r&t||}n
t||}tj||||||fS)z5Add a list of two-tuples to the uri query components.)r$rMZ
urlunparse)	urirZfragmentZschZnetpathZparr&Zfrarrradd_params_to_uris

rPcCsLt|t|krdSd}x*t||D]\}}|t|t|AO}q$W|dkS)a Near-constant time string comparison.

    Used in order to avoid timing attacks on sensitive information such
    as secret keys during request verification (`rootLabs`_).

    .. _`rootLabs`: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/

    Fr)lenzipord)abresultr9yrrrsafe_string_equals!s	rXUTF-8cst|tr|St|tr$t|dSt|dryt|Wn4tk
rNYnJtk
rnfdd|DSXt|dr|j}tfdd|DS|S)z:Convert a number of different types of objects to unicode.)encodingr)c3s|]}t|VqdS)N)rG)r8i)rZrrr<Bszto_unicode.<locals>.<genexpr>r.c3s&|]\}}t|t|fVqdS)N)rG)r8rr)rZrrr<Gs)rr
rr*r+r,r r.)datarZr)rZrrG3s



rGcsbeZdZdZiZddZddZfddZfdd	ZdddZ	fd
dZ
fddZZS)CaseInsensitiveDictz3Basic case insensitive dict with strings only keys.cCs2tdd|D|_x|D]}||||<qWdS)Ncss|]}|j|fVqdS)N)lower)r8rrrrr<Ssz/CaseInsensitiveDict.__init__.<locals>.<genexpr>)r+proxy)selfr\rrrr__init__Rs
zCaseInsensitiveDict.__init__cCs|j|jkS)N)r^r_)r`rrrr__contains__Wsz CaseInsensitiveDict.__contains__cs.|j|j}tt|j||j|j=dS)N)r_r^superr]__delitem__)r`rkey)	__class__rrrdZszCaseInsensitiveDict.__delitem__cs|j|j}tt|j|S)N)r_r^rcr]__getitem__)r`rre)rfrrrg_szCaseInsensitiveDict.__getitem__NcCs||kr||S|S)Nr)r`rdefaultrrrgetcszCaseInsensitiveDict.getcs$tt|j||||j|j<dS)N)rcr]__setitem__r_r^)r`rr)rfrrrjfszCaseInsensitiveDict.__setitem__cs8tt|j||x t||D]}||j|j<qWdS)N)rcr]rEr+r_r^)r`argskwargsr)rfrrrEjszCaseInsensitiveDict.update)N)
__name__
__module____qualname____doc__r_rarbrdrgrirjrE
__classcell__rr)rfrr]Ls
r]c@sNeZdZdZdddZddZd	d
ZeddZed
dZ	eddZ
dS)Requesta:A malleable representation of a signable HTTP request.

    Body argument may contain any data, but parameters will only be decoded if
    they are one of:

    * urlencoded query string
    * dict
    * list of 2-tuples

    Anything else will be treated as raw body data to be passed through
    unmolested.
    GETNutf-8csfdd}|||_|||_t||p*i|_|||_t|j|_g|_i|_dddddddddddddddddddddddddddd|_	|j	j
tt|j
|j	j
t|jpg|j	j
|jdS)Ncsrt|S|S)N)rG)r9)rZrr<lambda>sz"Request.__init__.<locals>.<lambda>)Zaccess_tokenZclientZ	client_idZ
client_secretcodeZextra_credentialsZ
grant_typeZredirect_uriZ
refresh_tokenZ
request_tokenZ
response_typerAZscopesstaterHuserZtoken_type_hintZ
response_modeZnonceZdisplaypromptrFZmax_ageZ
ui_localesZ
id_token_hintZ
login_hintZ
acr_values)rNhttp_methodr]headersbodyr0decoded_bodyZoauth_paramsZ
validator_log_paramsrEr+r(	uri_query)r`rNrzr|r{rZrr)rZrrasL



zRequest.__init__cCs ||jkr|j|St|dS)N)r~AttributeError)r`namerrr__getattr__s

zRequest.__getattr__cCsH|j}|jj}|r$tjdt|}d|kr4d|d<d|j|j||fS)Nz<SANITIZED>Z
Authorizationz<SANITIZED>zF<oauthlib.Request url="%s", http_method="%s", headers="%s", body="%s">)r|r{copySANITIZE_PATTERNsubstrrNrz)r`r|r{rrr__repr__s
zRequest.__repr__cCstj|jjS)N)r$rNr&)r`rrrrszRequest.uri_querycCs|js
gStj|jdddS)NT)rZstrict_parsing)rr$r%)r`rrruri_query_paramss
zRequest.uri_query_paramscCsTtjt}dd|jpg|jD}x|D]}||d7<q*Wdd|jDS)Ncss|]}|dVqdS)rNr)r8prrrr<sz+Request.duplicate_params.<locals>.<genexpr>cSsg|]\}}|dkr|qS)rr)r8rcrrr
<listcomp>sz,Request.duplicate_params.<locals>.<listcomp>)collectionsdefaultdictr4r}rr.)r`Z	seen_keysZall_keysrrrrduplicate_paramss

zRequest.duplicate_params)rsNNrt)rmrnrorprarrpropertyrrrrrrrrrps

/
rr)r)F)rY)>rpZ
__future__rrrrDZloggingresysr5ZsecretsrrImportErrorZrandomrZurllibrrrrr	rZurllib.parser$parseZUNICODE_ASCII_CHARACTER_SETZCLIENT_ID_CHARACTER_SETcompile
IGNORECASErr!Zalways_safeZ	getLoggerlogversion_infor#rr
bytesrZunicoderrrrr(r0r3r2r@rIrJrKrMrPrXrGr+r]objectrrrrrr<module>sr




	1		


$