view bitsyauth/factory.py @ 9:73b2b5bccd52

* allow logout to pass through instead of failing * add a basic filter factory for single-user bitsyauth wrapper which reads bitsyblog users directory as format (this needs to be factored apart later)
author egj@socialplanning.org
date Mon, 04 Jan 2010 03:14:01 +0000
parents c958eb9300da
children
line wrap: on
line source

from bitsyauth import BitsyAuth
from paste.auth import digest

def passworder_factory(username, database):
    def passwords():
        passwords = database.passwords()
        password = passwords[username]
        return {username: password}
    return passwords

def filter_factory(global_conf, **app_conf):

    user = app_conf['user']
    site = app_conf.get('site', 'bitsyauth')
    secret = app_conf.get('secret', 'secret')

    from bitsyblog.user import FilespaceUsers

    users_directory = FilespaceUsers(
        app_conf['users_directory'])

    passwords = passworder_factory(user, users_directory)

    def filter(app):
        ret = BitsyAuth(
            app,
            global_conf,
            passwords,
            newuser=None,
            site=site,
            secret=secret)
        return ret
    return filter