public
Description: An HTTP proxy for signing OAuth requests
Clone URL: git://github.com/mojodna/oauth-proxy.git
Search Repo:
removed pycs
mojodna (author)
Mon Apr 21 18:08:39 -0700 2008
commit  4e0f491277ff5968810f7b029071814e24d1eb0d
tree    d1b3fde8c8d6591f7db9a924eaf21970b73b32d4
parent  1f8ea16b4f98dabf724528cc7b74fa9fae734b6d
...
1
2
...
 
 
0
@@ -1,3 +1 @@
0
-³ò
0
-Â Hc@sdS(N((((s'/Users/seth/Documents/oauth/__init__.pys<module>s
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,69 +1 @@
0
-³ò
0
-©] Hc
0
-@spddkZddkZddkZddkZddkZddkZddkZdZdZdZ de
0
-fd„ƒYZ dd„Z d „Z d
0
-„Zd d „Zd efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿNs1.0tGETt PLAINTEXTt
0
-OAuthErrorcBseZdd„ZRS(sOAuth error occuredcCs ||_dS(N(tmessage(tselfR((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt__init__s(t__name__t
0
-__module__R(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRstcCshd|d<S(NsOAuth realm="%s"sWWW-Authenticate((trealm((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytbuild_authenticate_headerscCsti|ddƒS(Ntsafet~(turllibtquote(ts((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytescapescCsttiƒƒS(N(tintttime(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytgenerate_timestampsicCsdid„t|ƒDƒƒS(NRcss+x$|]}ttiddƒƒVqWdS(ii N(tstrtrandomtrandint(t.0ti((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pys <genexpr>#s(tjointrange(tlength((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytgenerate_nonce"st OAuthConsumercBseZdZdZd„ZRS(cCs||_||_dS(N(tkeytsecret(RRR((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR+s N(RRtNoneRRR(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR'st
0
-OAuthTokencBs>eZdZdZd„Zd„Zed„ƒZd„Z RS(cCs||_||_dS(N(RR(RRR((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR:s cCs%tih|id<|id<ƒS(Nt oauth_tokentoauth_token_secret(R t urlencodeRR(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt to_string>scCs>ti|dtƒ}|dd}|dd}t||ƒS(Ntkeep_blank_valuesR"iR#(tcgitparse_qstFalseR!(RtparamsRR((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt from_stringCscCs
0
-|iƒS(N(R%(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt__str__JsN(
0
-RRR RRRR%t staticmethodR+R,(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR!1s   t OAuthRequestcBseZdZdZeZdZeZ eddd„Z
0
-d„Z d„Z d„Z d„Zdd„Zd„Zd „Zd
0
-„Zd „Zd „Zd „Zd„Zedddd„ƒZededdd„ƒZededdd„ƒZed„ƒZed„ƒZRS(s
0
- OAuth parameters:
0
- - oauth_consumer_key
0
- - oauth_token
0
- - oauth_signature_method
0
- - oauth_signature
0
- - oauth_timestamp
0
- - oauth_nonce
0
- - oauth_version
0
- ... any additional parameters, as defined by the Service Provider.
0
- cCs&||_||_|ph|_dS(N(t http_methodthttp_urlt
0
-parameters(RR/R0R1((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR_s  cCs||i|<dS(N(R1(Rt parametertvalue((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt set_parameterdscCs-y|i|SWntd|ƒ‚nXdS(NsParameter not found: %s(R1R(RR2((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt get_parametergscCs|idƒ|idƒfS(Ntoauth_timestampt oauth_nonce(R5(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt_get_timestamp_noncemscCsNh}xA|iiƒD]0\}}|idƒdjo|||<qqW|S(Ntoauth_i(R1t iteritemstfind(RR1tktv((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytget_nonoauth_parametersqs  RcCsYd|}|io8x5|iiƒD] \}}|d||f7}q$Wnh|d<S(NsOAuth realm="%s"s , %s="%s"t Authorization(R1R:(RR t auth_headerR<R=((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt to_headerzs 
0
-
0
- cCs did„|iiƒDƒƒS(Nt&cssAx:|]3\}}dtt|ƒƒtt|ƒƒfVqWdS(s%s=%sN(RR(RR<R=((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pys <genexpr>„s(RR1R:(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt to_postdataƒscCsd|iƒ|iƒfS(Ns%s?%s(tget_normalized_http_urlRC(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytto_url‡scCsK|i}y |d=WnnX|iƒ}|iƒdid„|DƒƒS(Ntoauth_signatureRBcssAx:|]3\}}dtt|ƒƒtt|ƒƒfVqWdS(s%s=%sN(RR(RR<R=((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pys <genexpr>–s(R1titemstsortR(RR*t
0
-key_values((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytget_normalized_parameters‹s   
0
-cCs |iiƒS(N(R/tupper(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytget_normalized_http_method™scCs5ti|iƒ}d|d|d|df}|S(Ns %s://%s%siii(turlparseR0(Rtpartst
0
-url_string((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRDscCs?|id|iƒƒ|idt|i|||ƒƒƒdS(Ntoauth_signature_methodRF(R4tget_nameRtbuild_signature(Rtsignature_methodtconsumerttoken((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt sign_request£scCs|i|||ƒS(N(RR(RRSRTRU((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRR©scCs |dj ot|||ƒSn|dj oTy:|d}|idƒti|ƒ}t|||ƒSWq‚tdƒ‚q‚Xn|djo |dj oti|ƒ}n3|djo%ti|ƒi}ti|ƒ}n|ot|||ƒSntdƒ‚dS(NR?tOAuths;Unable to parse OAuth parameters from Authorization header.tPOSTRsYMissing all OAuth parameters. OAuth parameters must be in the headers, post body, or url.(R R.tindext _split_headerRt_split_url_stringRMtquery(R/R0theaderstpostdataR1R@t param_str((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt from_request­s$  
0
-  cCs‚|p
0
-h}nh|id<tƒd<tƒd<tid<}|i|ƒ|}|o|i|d<nt|||ƒS(Ntoauth_consumer_keyR6R7t oauth_versionR"(RRRR.tversiontupdate(toauth_consumerRUR/R0R1tdefaults((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytfrom_consumer_and_tokenÐs
0
-    cCsI|p
0
-h}n|i|d<|ot|ƒ|d<nt|||ƒS(NR"toauth_callback(RRR.(RUtcallbackR/R0R1((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytfrom_token_and_callbackäs 
0
- cCs‰h}|idƒ}xm|D]e}|idƒdjoqn|iƒ}|iddƒ}ti|didƒƒ||d<qW|S(Nt,s OAuth realmiÿÿÿÿt=is"i(tsplitR;tstripR tunquote(theaderR*RNtparamt param_parts((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRZñs (cCsMti|dtƒ}x1|iƒD]#\}}ti|dƒ||<q"W|S(NR&i(R'R(R)R:R Ro(R_R1R<R=((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR[s
0
- N(RRt__doc__R R1t HTTP_METHODR/R0tVERSIONRcRR4R5R8R>RARCRERJRLRDRVRRR-R`RgRjRZR[(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR.Ns4           " t OAuthServercBsÅeZdZeZdZdZddd„Zd„Z d„Z
0
-d„Z d„Z d„Z d„Zd„Zd „Zd
0
-d „Zd „Zd „Zd„Zdd„Zd„Zd„Zd„ZRS(i,cCs||_|ph|_dS(N(t
0
-data_storetsignature_methods(RRwRx((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRs cCs t|_dS(N(Rw(Rtoauth_data_store((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytset_data_storescCs|iS(N(Rw(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytget_data_storescCs||i|iƒ<|iS(N(RxRQ(RRS((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytadd_signature_methodscCsgy|i|dƒ}WnJ|i|ƒ}|i|ƒ}|i||dƒ|ii|ƒ}nX|S(Ntrequest(t
0
-_get_tokent _get_versiont _get_consumert_check_signatureR Rwtfetch_request_token(Rt oauth_requestRURcRT((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR‚ scCs\|i|ƒ}|i|ƒ}|i|dƒ}|i|||ƒ|ii||ƒ}|S(NR}(RR€R~RRwtfetch_access_token(RRƒRcRTRUt new_token((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR„/s cCs\|i|ƒ}|i|ƒ}|i|dƒ}|i|||ƒ|iƒ}|||fS(Ntaccess(RR€R~RR>(RRƒRcRTRUR1((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytverify_request9s  cCs|ii||ƒS(N(Rwtauthorize_request_token(RRUtuser((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytauthorize_tokenDscCs |idƒS(NRh(R5(RRƒ((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt get_callbackHsRcCshd|d<S(NsOAuth realm="%s"sWWW-Authenticate((RR ((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR
0
-LscCsXy|idƒ}Wn t}nX|o*||ijotdt|ƒƒ‚n|S(NRbsOAuth version %s not supported(R5RuRcRR(RRƒRc((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRPs
0
-cCspy|idƒ}Wn t}nXy|i|}Wn5di|iiƒƒ}td||fƒ‚nX|S(NRPs, s>Signature method %s not supported try one of the following: %s(R5tSIGNATURE_METHODRxRtkeysR(RRƒRStsignature_method_names((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt_get_signature_methodZs
0
-cCsS|idƒ}|ptdƒ‚n|ii|ƒ}|ptdƒ‚n|S(NRasInvalid consumer keysInvalid consumer(R5RRwtlookup_consumer(RRƒt consumer_keyRT((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR€hsR†cCsI|idƒ}|ii||ƒ}|ptd||fƒ‚n|S(NR"sInvalid %s token: %s(R5Rwt lookup_tokenR(RRƒt
0
-token_typet token_fieldRU((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR~rs
0
-c CsÈ|iƒ\}}|i|ƒ|i|||ƒ|i|ƒ}y|idƒ}Wntdƒ‚nX|i|||ƒ}||jo8|i|||ƒ\} }
0
-td|||
0
-fƒ‚ndS(NRFsMissing signaturesQSignature does not match. Expected: %s Got: %s Expected signature base string: %s(R8t_check_timestampt _check_nonceRR5RRRtbuild_signature_base_string( RRƒRTRUt timestamptnonceRSt signaturetbuiltRtbase((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRys  cCs\t|ƒ}ttiƒƒ}||}||ijo td|||ifƒ‚ndS(NsQExpired timestamp: given %d and now %s has a greater difference than threshold %d(RRttimestamp_thresholdR(RR˜tnowtlapsed((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR•ˆs
0
- 
0
-cCs>y0|ii|||ƒtdt|ƒƒ‚WnnXdS(NsNonce already used: %s(Rwt lookup_nonceRR(RRTRUR™((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR–s
0
-N(RRRRuRcR RxRwRRzR{R|R‚R„R‡RŠR‹R
0
-RRR€R~RR•R–(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRv
0
-s*    
0
-   
0
- 
0
-   t OAuthClientcBsJeZdZdZd„Zd„Zd„Zd„Zd„Z d„Z
0
-RS(cCs||_||_dS(N(RTRU(RReR"((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRs cCs|iS(N(RT(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt get_consumer¡scCs|iS(N(RU(R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyt get_token¤scCs
0
-t‚dS(N(tNotImplementedError(RRƒ((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR‚§scCs
0
-t‚dS(N(R¤(RRƒ((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR„«scCs
0
-t‚dS(N(R¤(RRƒ((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pytaccess_resource¯sN( RRR RTRURR¢R£R‚R„R¥(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR¡™s     tOAuthDataStorecBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs
0
-t‚dS(N(R¤(RR((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR¶scCs
0
-t‚dS(N(R¤(RReR“t token_token((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR’ºscCs
0
-t‚dS(N(R¤(RReR"R™R˜((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR ¾scCs
0
-t‚dS(N(R¤(RRe((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR‚ÂscCs
0
-t‚dS(N(R¤(RReR"((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR„ÆscCs
0
-t‚dS(N(R¤(RR"R‰((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRˆÊs(RRRR’R R‚R„Rˆ(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR¦´s      tOAuthSignatureMethodcBs#eZd„Zd„Zd„ZRS(cCs
0
-t‚dS(N(R¤(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRQÐscCs
0
-t‚dS(N(R¤(RƒReR"((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR—ÔscCs
0
-t‚dS(N(R¤(RƒReR"((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRRØs(RRRQR—RR(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR¨Ïs  tOAuthSignatureMethod_HMAC_SHA1cBs#eZd„Zd„Zd„ZRS(cCsdS(Ns HMAC-SHA1((R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRQÞscCs}t|iƒƒt|iƒƒt|iƒƒf}dt|iƒ}|o|t|iƒ7}ndi|ƒ}||fS(Ns%s&RB(RRLRDRJRR(RRƒRTRUtsigRtraw((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR—ásc Cs|i|||ƒ\}}y(ddk}ti|||iƒ}Wn(ddk}ti|||ƒ}nXti|iƒƒS(Niÿÿÿÿ( R—thashlibthmactnewtsha1tshatbase64t b64encodetdigest( RRƒRTRURR«R¬thashedR°((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRRîs  (RRRQR—RR(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR©Üs  tOAuthSignatureMethod_PLAINTEXTcBs#eZd„Zd„Zd„ZRS(cCsdS(NR((R((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRQÿscCs<t|iƒ}|o"di|t|iƒfƒ}n|S(NRB(RRR(RRƒRTRURª((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyR—s"cCs|i|||ƒS(N(R—(RRƒRTRU((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRR s(RRRQR—RR(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pyRµý  (R'R RRRMR­R±RuRtRŒt RuntimeErrorRR
0
-RRRtobjectRR!R.RvR¡R¦R¨R©Rµ(((s0/Users/seth/Documents/oauth_proxy/oauth/oauth.pys<module>s.           
0
-¼ !

Comments

    No one has commented yet.