%PDF- %PDF-
Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/auth/ |
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyo |
� a�Nc @ s� d Z d g Z d d l Z d d l Z d d l Z d d l Z d d l m Z d � Z d d l m Z d d l m Z d d l m Z d e f d � � YZ e Z d e e e e e d � Z d S( s� OpenID Authentication (Consumer) OpenID is a distributed authentication system for single sign-on originally developed at/for LiveJournal.com. http://openid.net/ URL. You can have multiple identities in the same way you can have multiple URLs. All OpenID does is provide a way to prove that you own a URL (identity). And it does this without passing around your password, your email address, or anything you don't want it to. There's no profile exchange component at all: your profiile is your identity URL, but recipients of your identity can then learn more about you from any public, semantically interesting documents linked thereunder (FOAF, RSS, Atom, vCARD, etc.). ``Note``: paste.auth.openid requires installation of the Python-OpenID libraries:: http://www.openidenabled.com/ This module is based highly off the consumer.py that Python OpenID comes with. Using the OpenID Middleware =========================== Using the OpenID middleware is fairly easy, the most minimal example using the basic login form thats included:: # Add to your wsgi app creation from paste.auth import open_id wsgi_app = open_id.middleware(wsgi_app, '/somewhere/to/store/openid/data') You will now have the OpenID form available at /oid on your site. Logging in will verify that the login worked. A more complete login should involve having the OpenID middleware load your own login page after verifying the OpenID URL so that you can retain the login information in your webapp (session, cookies, etc.):: wsgi_app = open_id.middleware(wsgi_app, '/somewhere/to/store/openid/data', login_redirect='/your/login/code') Your login code should then be configured to retrieve 'paste.auth.open_id' for the users OpenID URL. If this key does not exist, the user has not logged in. Once the login is retrieved, it should be saved in your webapp, and the user should be redirected to wherever they would normally go after a successful login. t AuthOpenIDHandleri����N( t httpexceptionsc C s t j | d � } d | f S( Ni s "%s"( t cgit escape( t st qs( ( sC /opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyt quoteattrA s ( t filestore( t consumer( t appendArgsc B s� e Z d Z d d e d d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d d d d d d � Z d � Z d � Z RS( sq This middleware implements OpenID Consumer behavior to authenticate a URL against an OpenID Server. s /oidc C s[ t j | � } t j | � | _ | | _ | | _ | | _ | | _ | | _ | | _ d S( s� Initialize the OpenID middleware ``app`` Your WSGI app to call ``data_store_path`` Directory to store crypto data in for use with OpenID servers. ``auth_prefix`` Location for authentication process/verification ``login_redirect`` Location to load after successful process of login ``catch_401`` If true, then any 401 responses will turn into open ID login requirements. ``url_to_username`` A function called like ``url_to_username(environ, url)``, which should return a string username. If not given, the URL will be the username. N( R t FileOpenIDStoreR t OpenIDConsumert oidconsumert appt auth_prefixt data_store_patht login_redirectt catch_401t url_to_username( t selfR R R R R R t store( ( sC /opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyt __init__U s c C s; | d j | j � rt d | d | d g � } t j j | d t d t �| d <t j | j d | d � } t j | � | d <t t j j | � � | d <| d d } | d k s� | r� | j | � S| d k r� | j | � S| d k r� | j | � S| j | � Sn) | j r'| j | | � S| j | | � Sd S( Nt PATH_INFOt environt startt bodyt with_path_infot with_query_stringt base_urlt t parsed_urit queryi t /s /verifys /process( t startswithR t dictt pastet requestt construct_urlt Falset ret subt urlparset parse_querystringt rendert do_verifyt do_processt not_foundR t catch_401_app_callR ( R R t start_responseR$ t path( ( sC /opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyt __call__y s$ c s� g � d � � f d � } | j | | � } � r� z t | � Wd t | d � r` | j � n Xt j j | d t d t �} t j | � } | j | � � S| Sd S( sV Call the application, and redirect if the app returns a 401 response c sL t | j d d � � d k r8 � j d � d � } | S� | | | � Sd S( Ni i� c S s d S( N( ( t v( ( sC /opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyt dummy_writer� s ( t intt splitt Nonet append( t statust headerst exc_infoR4 ( R0 t was_401( sC /opt/alt/python27/lib/python2.7/site-packages/paste/auth/open_id.pyt replacement_start_response� s Nt closeR R ( R7 R t listt hasattrR>