Mercurial > hg > bitsyauth
changeset 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 | 16c33fd5fb20 |
files | bitsyauth/__init__.py bitsyauth/factory.py |
diffstat | 2 files changed, 22 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/bitsyauth/__init__.py Mon Jan 04 01:46:25 2010 +0000 +++ b/bitsyauth/__init__.py Mon Jan 04 03:14:01 2010 +0000 @@ -350,14 +350,19 @@ # self.cookie_handler = cookie.middleware(auth, cookie_name=self.cookie, timeout=90) # minutes # paste.auth.auth_tkt - self.cookie_handler = auth_tkt.make_auth_tkt_middleware(auth, global_conf, secret, cookie_name=self.cookie, logout_path='/logout') + self.cookie_handler = auth_tkt.make_auth_tkt_middleware( + auth, global_conf, secret, + cookie_name=self.cookie, logout_path='/logout') def __call__(self, environ, start_response): if environ['PATH_INFO'] == '/logout': - pass - return self.cookie_handler(environ, start_response) + pass + try: + return self.cookie_handler(environ, start_response) + except: + return self.logout(environ, start_response) - def logout(self, environ): + def logout(self, environ, start_response): req = Request(environ) keys = [ 'REMOTE_USER' ] # keys = [ 'REMOTE_USER', 'AUTH_TYPE', 'paste.auth.cookie', 'paste.cookies', 'HTTP_COOKIE' ] # XXX zealous kill
--- a/bitsyauth/factory.py Mon Jan 04 01:46:25 2010 +0000 +++ b/bitsyauth/factory.py Mon Jan 04 03:14:01 2010 +0000 @@ -1,26 +1,33 @@ from bitsyauth import BitsyAuth from paste.auth import digest -def passworder_factory(username, password): +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') - password = app_conf['password'] - password = digest.digest_password(site, user, password) - passwords = passworder_factory(user, password) + + from bitsyblog.user import FilespaceUsers + + users_directory = FilespaceUsers( + app_conf['users_directory']) + + passwords = passworder_factory(user, users_directory) def filter(app): - return BitsyAuth( + ret = BitsyAuth( app, global_conf, passwords, newuser=None, site=site, secret=secret) + return ret return filter