ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ aNc@s dZddlZyddlmZWn!ek rIddlmZnXddlZddlmZddl m Z ddl m Z defdYZd efd YZd Zd Zd ZddZdefdYZddeeddZdS(s' Implementation of cookie signing as done in `mod_auth_tkt `_. mod_auth_tkt is an Apache module that looks for these signed cookies and sets ``REMOTE_USER``, ``REMOTE_USER_TOKENS`` (a comma-separated list of groups) and ``REMOTE_USER_DATA`` (arbitrary string data). This module is an alternative to the ``paste.auth.cookie`` module; it's primary benefit is compatibility with mod_auth_tkt, which in turn makes it possible to use the same authentication process with non-Python code run under Apache. iN(tmd5(trequest(tquote(tunquotet AuthTicketcBsAeZdZddddedZdZdZdZRS( s This class represents an authentication token. You must pass in the shared secret, the userid, and the IP address. Optionally you can include tokens (a list of strings, representing role names), 'user_data', which is arbitrary data available for your own use in later scripts. Lastly, you can override the cookie name and timestamp. Once you provide all the arguments, use .cookie_value() to generate the appropriate authentication ticket. .cookie() generates a Cookie object, the str() of which is the complete cookie header to be sent. CGI usage:: token = auth_tkt.AuthTick('sharedsecret', 'username', os.environ['REMOTE_ADDR'], tokens=['admin']) print 'Status: 200 OK' print 'Content-type: text/html' print token.cookie() print ... redirect HTML ... Webware usage:: token = auth_tkt.AuthTick('sharedsecret', 'username', self.request().environ()['REMOTE_ADDR'], tokens=['admin']) self.response().setCookie('auth_tkt', token.cookie_value()) Be careful not to do an HTTP redirect after login; use meta refresh or Javascript -- some browsers have bugs where cookies aren't saved when set on a redirect. ttauth_tktc Css||_||_||_dj||_||_|dkrTtj|_n ||_||_ ||_ dS(Nt,( tsecrettuseridtiptjointtokenst user_datatNonettime_modttimet cookie_nametsecure( tselfRR R R R RRR((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyt__init__Ws       cCs+t|j|j|j|j|j|jS(N(tcalculate_digestR RRR R R (R((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pytdigestfscCsYd|jt|jt|jf}|jrH||jd7}n||j7}|S(Ns %s%08x%s!t!(RtintRt url_quoteR R R (Rtv((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyt cookie_valueks +  cCsltj}|jjdjjdd||j`_ looks for (if you have mod_auth_tkt installed, you don't need this middleware, since Apache will set the environmental variables for you). Arguments: ``secret``: A secret that should be shared by any instances of this application. If this app is served from more than one machine, they should all have the same secret. ``cookie_name``: The name of the cookie to read and write from. Default ``auth_tkt``. ``secure``: If the cookie should be set as 'secure' (only sent over SSL) and if the login must be over SSL. (Defaults to False) ``httponly``: If the cookie should be marked as HttpOnly, which means that it's not accessible to JavaScript. (Defaults to False) ``include_ip``: If the cookie should include the user's IP address. If so, then if they change IPs their cookie will be invalid. ``logout_path``: The path under this middleware that should signify a logout. The page will be shown as usual, but the user will also be logged out when they visit this page. If used with mod_auth_tkt, then these settings (except logout_path) should match the analogous Apache configuration settings. This also adds two functions to the request: ``environ['paste.auth_tkt.set_user'](userid, tokens='', user_data='')`` This sets a cookie that logs the user in. ``tokens`` is a string (comma-separated groups) or a list of strings. ``user_data`` is a string for your own use. ``environ['paste.auth_tkt.logout_user']()`` Logs out the user. Rc Cs^||_||_||_||_||_||_||_||_| |_| |_ dS(N( tappRRRthttponlyt include_ipt logout_pathtno_domain_cookietcurrent_domain_cookietwildcard_cookie( RRIRRRRKRLRJRMRNRO((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyRs         c stj}j|kr1|jj}nd}|rjrSd}nd}ytj||\}}}} dj|}|d<jdrdd|}n|d<| dsB                cCs}|jd|jd}d|}d}dd|j|ffdd|j||ffdd|j||ffg}|S(NRhRiR<sSat, 01-Jan-2000 12:00:00 GMTs Set-Cookies%s=""; Expires="%s"; Path=/s&%s=""; Expires="%s"; Path=/; Domain=%s(RdR(RRWRlRmtexpiresRe((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyRZgs N( R'R(R)R*tTrueRRRgRVRZ(((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyRHs2  2 )RcCszddlm}||}||}|dkrF|jd}n|s[tdnt||||||pvdS(s Creates the `AuthTKTMiddleware `_. ``secret`` is requird, but can be set globally or locally. i(tasboolRs>You must provide a 'secret' (in global or local configuration)N(tpaste.deploy.convertersRqRRdR0RH(RIt global_confRRRRKRLRq((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pytmake_auth_tkt_middlewareus    (R)RRthashlibRt ImportErrorR tpasteRturllibRRRR2tobjectRR-R+R7RR9R8RHRR*RpRt(((sD/opt/alt/python27/lib/python2.7/site-packages/paste/auth/auth_tkt.pyt&s*   H %