"""
from authkit.authenticate import AddDictToEnviron
-from authkit.authorize import NotAuthorizedError
+from authkit.authorize import NotAuthenticatedError, NotAuthorizedError
from authkit.permissions import RequestPermission
from sqlalchemy.exceptions import InvalidRequestError
if 'REMOTE_USER' not in environ:
raise NotAuthenticatedError('Not Authenticated')
try:
- user = meta.Session.query(model.User).\
- filter_by(username=environ['REMOTE_USER']).\
+ environ['user'] = meta.Session.query(model.User).\
+ filter_by(username=unicode(environ['REMOTE_USER'])).\
one()
except InvalidRequestError:
raise NotAuthorizedError('You are not allowed access.')
Set the authkit.authenticate environment variable so
authkit.authorize shuts up
"""
- def __init__(self, app):
- super(DummyAuthenticate, self).__init__(app, {
- 'authkit.authenticate': True})
+ def __init__(self, app, app_conf):
+ newenv = {}
+ newenv['authkit.authenticate'] = True
+ if 'fake_username' in app_conf:
+ newenv['REMOTE_USER'] = app_conf['fake_username']
+ super(DummyAuthenticate, self).__init__(app, newenv)
__all__ = ['BlueChipUser', 'DummyAuthenticate']