Viewing File: /usr/lib/python2.7/site-packages/requests/auth.pyo

ó
4£ëTc@sdZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
mZddlmZd	Zd
Zd„Zdefd
„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s]
requests.auth
~~~~~~~~~~~~~

This module contains the authentication handlers for Requests.
iÿÿÿÿN(t	b64encodei(turlparsetstr(textract_cookies_to_jar(tparse_dict_headertto_native_string(tcodess!application/x-www-form-urlencodedsmultipart/form-datacCs3dttd||fjdƒƒjƒƒ}|S(sReturns a Basic Auth string.sBasic s%s:%stlatin1(RRtencodetstrip(tusernametpasswordtauthstr((s1/usr/lib/python2.7/site-packages/requests/auth.pyt_basic_auth_strs)tAuthBasecBseZdZd„ZRS(s4Base class that all auth implementations derive fromcCstdƒ‚dS(NsAuth hooks must be callable.(tNotImplementedError(tselftr((s1/usr/lib/python2.7/site-packages/requests/auth.pyt__call__'s(t__name__t
__module__t__doc__R(((s1/usr/lib/python2.7/site-packages/requests/auth.pyR$st
HTTPBasicAuthcBs eZdZd„Zd„ZRS(s?Attaches HTTP Basic Authentication to the given Request object.cCs||_||_dS(N(R
R(RR
R((s1/usr/lib/python2.7/site-packages/requests/auth.pyt__init__-s	cCs t|j|jƒ|jd<|S(Nt
Authorization(R
R
Rtheaders(RR((s1/usr/lib/python2.7/site-packages/requests/auth.pyR1s(RRRRR(((s1/usr/lib/python2.7/site-packages/requests/auth.pyR+s	t
HTTPProxyAuthcBseZdZd„ZRS(s=Attaches HTTP Proxy Authentication to a given Request object.cCs t|j|jƒ|jd<|S(NsProxy-Authorization(R
R
RR(RR((s1/usr/lib/python2.7/site-packages/requests/auth.pyR8s(RRRR(((s1/usr/lib/python2.7/site-packages/requests/auth.pyR6stHTTPDigestAuthcBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(s@Attaches HTTP Digest Authentication to the given Request object.cCsC||_||_d|_d|_i|_d|_d|_dS(Ntii(R
Rt
last_noncetnonce_counttchaltNonetpost
num_401_calls(RR
R((s1/usr/lib/python2.7/site-packages/requests/auth.pyR?s						cs'|jd}|jd}|jjdƒ}|jjdƒ}|jjdƒ}|dkred}n|jƒ}|dks‰|dkr›d„}	|	‰n|d	kr¹d
„}
|
‰n‡fd†}ˆdkrØdSd}t|ƒ}
|
j}|
jr|d|
j7}nd
|j||jf}d||f}ˆ|ƒ}ˆ|ƒ}||j	krr|j
d7_
n	d|_
d|j
}t|j
ƒjdƒ}||jdƒ7}|t
jƒjdƒ7}|tjdƒ7}tj|ƒjƒd }|dkr ˆd
|||fƒ}n|dkrH||d||fƒ}nP|dksid|jdƒkr”d|||d|f}|||ƒ}ndS||_	d|j||||f}|rÔ|d|7}n|rë|d|7}n|r|d|7}n|r|d||f7}nd|S(Ntrealmtnoncetqopt	algorithmtopaquetMD5sMD5-SESScSs4t|tƒr!|jdƒ}ntj|ƒjƒS(Nsutf-8(t
isinstanceRRthashlibtmd5t	hexdigest(tx((s1/usr/lib/python2.7/site-packages/requests/auth.pytmd5_utf8VstSHAcSs4t|tƒr!|jdƒ}ntj|ƒjƒS(Nsutf-8(R)RRR*tsha1R,(R-((s1/usr/lib/python2.7/site-packages/requests/auth.pytsha_utf8\scsˆd||fƒS(Ns%s:%s((tstd(t	hash_utf8(s1/usr/lib/python2.7/site-packages/requests/auth.pyt<lambda>bst?s%s:%s:%ss%s:%sis%08xsutf-8iitautht,s%s:%s:%s:%s:%ss>username="%s", realm="%s", nonce="%s", uri="%s", response="%s"s
, opaque="%s"s, algorithm="%s"s
, digest="%s"s , qop="auth", nc=%s, cnonce="%s"s	Digest %s(RtgetR tupperRtpathtqueryR
RRRRRttimetctimetosturandomR*R0R,tsplit(RtmethodturlR#R$R%R&R't
_algorithmR.R1tKDtentdigtp_parsedR;tA1tA2tHA1tHA2tncvalueR2tcnoncetrespdigtnoncebittbase((R4s1/usr/lib/python2.7/site-packages/requests/auth.pytbuild_digest_headerHsp

								
!	cKs|jrd|_ndS(s)Reset num_401_calls counter on redirects.iN(tis_redirectR"(RRtkwargs((s1/usr/lib/python2.7/site-packages/requests/auth.pythandle_redirects	cKs_|jdk	r(|jjj|jƒnt|ddƒ}|jjddƒ}d|jƒkrR|dkrR|j	d7_	t
jddt
jƒ}t
|jd|d	dƒƒ|_|j|jjƒ|jjƒ}t|j|j|jƒ|j|jƒ|j|j|jƒ|jd
<|jj||}|jj|ƒ||_|Sd|_	|S(s:Takes the given response and tries digest-auth, if needed.R"iswww-authenticateRtdigestisdigest tflagstcountRN(R!R trequesttbodytseektgetattrRR9tlowerR"tretcompilet
IGNORECASERtsubRtcontenttrawtrelease_conntcopyRt_cookiestprepare_cookiesRQRBRCt
connectiontsendthistorytappend(RRRSR"ts_authtpattprept_r((s1/usr/lib/python2.7/site-packages/requests/auth.pyt
handle_401¢s*!
		cCsˆ|jr+|j|j|jƒ|jd<ny|jjƒ|_Wntk
r]d|_nX|j
d|jƒ|j
d|jƒ|S(NRtresponse(
RRQRBRCRRYttellR!tAttributeErrorR t
register_hookRoRT(RR((s1/usr/lib/python2.7/site-packages/requests/auth.pyRÅs	"

(RRRRRQRTRoR(((s1/usr/lib/python2.7/site-packages/requests/auth.pyR=s			U		#(RR?R]R=R*tbase64RtcompatRRtcookiesRtutilsRRtstatus_codesRtCONTENT_TYPE_FORM_URLENCODEDtCONTENT_TYPE_MULTI_PARTR
tobjectRRRR(((s1/usr/lib/python2.7/site-packages/requests/auth.pyt<module>s 	

Back to Directory File Manager