[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7917 - trunk/gnue-appserver/src
From: |
johannes |
Subject: |
[gnue] r7917 - trunk/gnue-appserver/src |
Date: |
Wed, 28 Sep 2005 12:35:22 -0500 (CDT) |
Author: johannes
Date: 2005-09-19 05:10:46 -0500 (Mon, 19 Sep 2005)
New Revision: 7917
Modified:
trunk/gnue-appserver/src/geasAuthentication.py
trunk/gnue-appserver/src/geasSessionManager.py
Log:
Removed internal session from geasAuthAgent and from SessionManager
Modified: trunk/gnue-appserver/src/geasAuthentication.py
===================================================================
--- trunk/gnue-appserver/src/geasAuthentication.py 2005-09-19 09:44:26 UTC
(rev 7916)
+++ trunk/gnue-appserver/src/geasAuthentication.py 2005-09-19 10:10:46 UTC
(rev 7917)
@@ -22,6 +22,7 @@
# $Id$
from gnue.common.apps import errors
+from gnue.appserver import data
# =============================================================================
# Exceptions
@@ -72,12 +73,14 @@
# Initalize
# ---------------------------------------------------------------------------
- def __init__ (self, internalSession):
+ def __init__ (self, connectionManager, database):
# creation and populating the user/password/tablelist list should be
# moved here, when the management interface is implemented and an easy
# way to update permissions is working
- self._intSess = internalSession
+ self._connections = connectionManager
+ self._database = database
+
# ---------------------------------------------------------------------------
# authenticate an user
# user contains the user name
@@ -86,32 +89,45 @@
# ---------------------------------------------------------------------------
def authenticate (self, session, user, auth):
- authList = self._intSess.request ("gnue_useraccess",
- ['eq', ['field', 'gnue_username'], ['const', user]],
- [],
- ["gnue_username", "gnue_password",
- "gnue_accesslist"])
- authData = self._intSess.fetch (authList, 0, 10)
+ conn = data.connection (self._connections, self._database)
+ try:
+ fields = [u'gnue_username', u'gnue_password', u'gnue_accesslist']
+ contents = {None: (u'gnue_useraccess', None, None, fields)}
+ resultSet = conn.query (contents, {u'gnue_username': user}, [])
- if len (authData) == 0:
- raise AuthError, u_("User '%s' does not exist.") % user
+ try:
+ hits = resultSet.count ()
- if len (authData) > 1:
- raise AuthError, u_("Internal Error: More than one (%(numrec)s) record "
- "for user '%(username)s'.") \
- % {"numrec" : len (authData), "username": user}
+ if not hits:
+ raise AuthError, u_("User '%s' does not exist.") % user
- if authData [0] [2] != auth ['password']:
- raise AuthError, u_("Invalid password for user '%s'") % user
+ elif hits > 1:
+ raise AuthError, \
+ u_("Internal Error: More than one (%(numrec)s) record " \
+ "for user '%(username)s'.") \
+ % {"numrec" : hits, "username": user}
- assert gDebug (1, "User '%s' logged in." % user)
+ rec = resultSet.nextRecord ()
- # possibly not the best solution
- session.tablelist = authData[0][3].split (',')
+ if rec.getField (u'gnue_password') != auth ['password']:
+ raise AuthError, u_("Invalid password for user '%s'") % user
- return 1 # = has access
+ assert gDebug (1, "User '%s' logged in." % user)
+ session.tablelist = rec.getField (u'gnue_accesslist').split (',')
+
+ finally:
+ resultSet.close ()
+
+ return 1
+
+ finally:
+ conn.close ()
+
+ return True
+
+
# ---------------------------------------------------------------------------
# check if user x has access for class/table y
# ---------------------------------------------------------------------------
@@ -123,8 +139,9 @@
if 'all' in tables or classname in tables:
return True
else:
- assert gDebug (1, "User '%(username)s' has no access to class
%(classname)s." \
- % {"username" : user, "classname": classname})
+ assert gDebug (1, "User '%(username)s' has no access to class "
+ "%(classname)s." \
+ % {"username" : user, "classname": classname})
return False
# =============================================================================
Modified: trunk/gnue-appserver/src/geasSessionManager.py
===================================================================
--- trunk/gnue-appserver/src/geasSessionManager.py 2005-09-19 09:44:26 UTC
(rev 7916)
+++ trunk/gnue-appserver/src/geasSessionManager.py 2005-09-19 10:10:46 UTC
(rev 7917)
@@ -56,7 +56,6 @@
def __init__ (self, connections, modulepath = None, scanModules = False):
self._connections = connections
self._sessions = {}
- self._buildInternalSession ()
self._modulepath = modulepath or \
os.path.join (paths.data, "share", "gnue", "appserver")
@@ -67,8 +66,8 @@
dbauth = cfg.get ('authentication', 'False')
if dbauth.lower () in ['true', 'yes', 'y']:
assert gDebug (1, "Using DB Auth Agent")
- self._authAdapter = geasAuthentication.geasDBAuthAgent ( \
- self._internalSession)
+ self._authAdapter = geasAuthentication.geasDBAuthAgent (connections,
+ gConfig ('connection'))
else:
assert gDebug (1, "Using dummy Auth Agent")
self._authAdapter = geasAuthentication.geasAuthAgent ()
@@ -77,22 +76,6 @@
# ---------------------------------------------------------------------------
- # Build an internal session
- # ---------------------------------------------------------------------------
-
- def _buildInternalSession (self):
-
- self._internalSession = geasSession.geasSession (self._connections,
- geasAuthentication.geasAuthAgent(), self, {})
- self._internalSession.login (None, None) # fake login
-
- # Some parts of the code access with session ID 0, so we have to store it
- # as "session zero", too. The correct session id is used for procedure
- # calls.
- self._sessions [id (self._internalSession)] = self._internalSession
- self._sessions [0] = self._internalSession
-
- # ---------------------------------------------------------------------------
# Find a session from session ID
# ---------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7917 - trunk/gnue-appserver/src,
johannes <=