]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/lib/permissions.py
Build in fakeauth into the fake authkit.authenticate module
[bluechips.git] / bluechips / lib / permissions.py
index 393cc6c3048ef528f0390c651de5f0ea5d28d8b4..a22eb0b0e130c4a372755a02de94bd3ee85849e2 100644 (file)
@@ -3,7 +3,7 @@ authkit authorization permission objects for BlueChips
 """
 
 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
@@ -28,8 +28,11 @@ class DummyAuthenticate(AddDictToEnviron):
     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']