Changeset 133

Show
Ignore:
Timestamp:
11/05/07 16:53:37
Author:
thejimmyg
Message:

Added a new user management API which is set up per request.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AuthKit/trunk/AuthKit.egg-info/PKG-INFO

    r128 r133  
    11Metadata-Version: 1.0 
    22Name: AuthKit 
    3 Version: 0.4.0-r127 
     3Version: 0.4.1dev-r132 
    44Summary: An authentication and authorization toolkit for WSGI applications and frameworks 
    55Home-page: http://authkit.org/ 
     
    3232         
    3333        * `Download and Installation <http://python.org/pypi/AuthKit/0.4.0>`_ 
    34         * `Pylons Book <http://pylonsbook.com>`_ (the two chapters on Authentication and 
    35         Authorization and Advanced AuthKit form the AuthKit 0.4 documentation) 
     34        * `Pylons Book <http://pylonsbook.com>`_ (the two chapters on *Authentication and 
     35        Authorization* and *Advanced AuthKit* form the AuthKit 0.4 documentation) 
    3636        * `Module Reference <http://authkit.org/docs/0.4/module-index.html>`_ 
     37        * `AuthKit Cookbook <http://wiki.pylonshq.com/display/authkitcookbook/Home>`_ 
    3738        * `Trac <http://authkit.org/trac>`_ - Tickets, Wiki, Subversion 
    3839        * `Examples <http://authkit.org/trac/browser/AuthKit/trunk/examples>`_ 
     
    5051        ======= 
    5152         
    52         0.4 (**svn**) 
     53        0.4.1 (**svn**) 
    5354         
    54         *** AS A RESULT OF THESE CHANGES THE DOCS ARE CURRENTLY OUT OF DATE *** 
     55        * Added a user management api_version attribute and changed the API so that 
     56        the users object is set up on each request and recieves an environ 
     57        argument. 
     58        * Fixed encrypt typo with postgres users driver 
     59         
     60        0.4.0 
    5561         
    5662        * Added support for encrypted passwords 
  • AuthKit/trunk/CHANGELOG.txt

    r128 r133  
    22======= 
    33 
    4 0.4 (**svn**) 
     40.4.1 (**svn**) 
    55 
    6 *** AS A RESULT OF THESE CHANGES THE DOCS ARE CURRENTLY OUT OF DATE *** 
     6* Added a user management api_version attribute and changed the API so that 
     7  the users object is set up on each request and recieves an environ 
     8  argument. 
     9* Fixed encrypt typo with postgres users driver 
     10 
     110.4.0  
    712 
    813* Added support for encrypted passwords 
  • AuthKit/trunk/authkit/authenticate/__init__.py

    r120 r133  
    125125        return True 
    126126    return False 
     127 
    127128 
    128129def digest_password(environ, realm, username): 
     
    156157    # correct thing: 
    157158    return None 
     159 
     160class AddUsersObjectToEnviron(object): 
     161    """Simple middleware which adds a Users object to the environ.""" 
     162    def __init__(self, app, key, value, *k, **p): 
     163        self.app = app 
     164        self.k = k 
     165        self.p = p 
     166        self.key = key 
     167        self.value = value 
     168 
     169    def __call__(self, environ, start_response): 
     170        p = {} 
     171        p.update(self.p) 
     172        p['environ'] = environ 
     173        environ[self.key] = self.value(*self.k, **p) 
     174        return self.app(environ, start_response) 
    158175 
    159176def get_authenticate_function(app, authenticate_conf, format, prefix): 
     
    189206            if isinstance(user_object, (str, unicode)): 
    190207                user_object = eval_import(user_object) 
    191             users = user_object(user_conf['data'], encrypt) 
    192             app = AddToEnviron(app, 'authkit.users', users) 
    193             log.debug("authkit.users added to environ") 
     208 
     209            if not hasattr(user_object, "api_version"): 
     210                users = user_object(user_conf['data'], encrypt) 
     211                app = AddToEnviron(app, 'authkit.users', users) 
     212                log.debug("authkit.users added to environ") 
     213            elif user_object.api_version == 0.4: 
     214                app = AddUsersObjectToEnviron( 
     215                    app,  
     216                    'authkit.users',  
     217                    user_object,  
     218                    encrypt=encrypt,  
     219                    data=user_conf['data'] 
     220                ) 
     221                log.debug("Setting up authkit.users middleware") 
     222            else: 
     223                raise Exception( 
     224                    'Unknown API version %s for user management API'%( 
     225                        users.api_version, 
     226                    ) 
     227                )          
    194228            if format == 'basic': 
    195229                function = valid_password 
  • AuthKit/trunk/authkit/users/postgresql_driver.py

    r131 r133  
    1515    Raw SQL Version 
    1616    """ 
    17     def __init__(self, data, encrypt=None): 
     17    api_version = 0.4 
     18 
     19    def __init__(self, environ, data, encrypt=None): 
    1820        if encrypt is None: 
    1921            def encrypt(password): 
     
    3335                ) 
    3436        self.get_conn, self.release_conn = data 
     37        self.environ = environ 
    3538 
    3639    def create_tables(self):