commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue-appserver samples/setup-pgsql.sh src/geasA...


From: Jan Ischebeck
Subject: gnue-appserver samples/setup-pgsql.sh src/geasA...
Date: Sat, 16 Aug 2003 13:07:17 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-appserver
Branch:         
Changes by:     Jan Ischebeck <address@hidden>  03/08/16 13:07:16

Modified files:
        samples        : setup-pgsql.sh 
        src            : geasAuthentication.py geasSession.py 
                         geasSessionManager.py 
        src/classrep   : __init__.py Class.py 
        src/language   : Session.py 

Log message:
        - use an internal session for classrep, authagent...
        - reenable authentication
        - add meta data for authentication data class

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/samples/setup-pgsql.sh.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasAuthentication.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasSession.py.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/geasSessionManager.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/__init__.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/classrep/Class.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-appserver/src/language/Session.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text

Patches:
Index: gnue-appserver/samples/setup-pgsql.sh
diff -c gnue-appserver/samples/setup-pgsql.sh:1.8 
gnue-appserver/samples/setup-pgsql.sh:1.9
*** gnue-appserver/samples/setup-pgsql.sh:1.8   Wed Aug 13 11:06:16 2003
--- gnue-appserver/samples/setup-pgsql.sh       Sat Aug 16 13:07:16 2003
***************
*** 264,280 ****
  -- Authentication and Trigger Test Stuff - TODO: Remove this
  -- 
============================================================================
  
! create table appserver_users 
  ( 
!   username character varying (20),
!   password character varying (20),
!   tablelist text
  );
! insert into appserver_users values ('test','test','address_person');
! insert into appserver_users values ('hacker','secret','address_person');
  
  create table appserver_pytrigger 
  (
     name character varying(30),
     event character varying(30),
     code text
--- 264,343 ----
  -- Authentication and Trigger Test Stuff - TODO: Remove this
  -- 
============================================================================
  
! -- 
----------------------------------------------------------------------------
! -- useraccess
! -- 
----------------------------------------------------------------------------
! 
! insert into gnue_class values
! (
!   '00000000000000000000000000000060',
!   '00000000000000000000000000000000',
!   'useraccess',
!   'GNU Enterprise User Authentication'
! );
! 
! insert into gnue_property values
! (
!   '00000000000000000000000000000061',
!   '00000000000000000000000000000060',
!   '00000000000000000000000000000000',
!   'id',
!   'id',
!   '0',
!   '0',
!   'Object ID'
! );
! 
! insert into gnue_property values
! (
!   '00000000000000000000000000000062',
!   '00000000000000000000000000000060',
!   '00000000000000000000000000000000',
!   'username',
!   'string',
!   '20',
!   '0',
!   'Username'
! );
! 
! insert into gnue_property values
! (
!   '00000000000000000000000000000062',
!   '00000000000000000000000000000060',
!   '00000000000000000000000000000000',
!   'password',
!   'string',
!   '20',
!   '0',
!   'Password'
! );
! 
! insert into gnue_property values
! (
!   '00000000000000000000000000000063',
!   '00000000000000000000000000000060',
!   '00000000000000000000000000000000',
!   'accesslist',
!   'string',
!   '255',
!   '0',
!   'List of classes with access allowed'
! );
! 
! create table gnue_useraccess 
  ( 
!   gnue_id character          (32),
!   gnue_username character varying (20),
!   gnue_password character varying (20),
!   gnue_accesslist text
  );
! insert into gnue_useraccess values 
('00000000000000000000000010000001','test','test','address_person');
! insert into gnue_useraccess values 
('00000000000000000000000010000002','hacker','secret','address_person');
! 
  
  create table appserver_pytrigger 
  (
+    gnue_id character      (32),
     name character varying(30),
     event character varying(30),
     code text
Index: gnue-appserver/src/classrep/Class.py
diff -c gnue-appserver/src/classrep/Class.py:1.5 
gnue-appserver/src/classrep/Class.py:1.6
*** gnue-appserver/src/classrep/Class.py:1.5    Tue Aug 12 11:01:05 2003
--- gnue-appserver/src/classrep/Class.py        Sat Aug 16 13:07:16 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: Class.py,v 1.5 2003/08/12 15:01:05 reinhard Exp $
  
  from Base import *
  from Namespace import *
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: Class.py,v 1.6 2003/08/16 17:07:16 siesel Exp $
  
  from Base import *
  from Namespace import *
***************
*** 99,105 ****
      module = self.modules [moduleName]
  
      # is the class already cached ?
!     if self.has_key (name):
        return self._cache [name]
  
      # since we had no match cached, ask for it
--- 99,105 ----
      module = self.modules [moduleName]
  
      # is the class already cached ?
!     if self._cache.has_key(name):
        return self._cache [name]
  
      # since we had no match cached, ask for it
Index: gnue-appserver/src/classrep/__init__.py
diff -c gnue-appserver/src/classrep/__init__.py:1.7 
gnue-appserver/src/classrep/__init__.py:1.8
*** gnue-appserver/src/classrep/__init__.py:1.7 Thu Aug 14 17:05:48 2003
--- gnue-appserver/src/classrep/__init__.py     Sat Aug 16 13:07:16 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: __init__.py,v 1.7 2003/08/14 21:05:48 btami Exp $
  
  import os, sys
  
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: __init__.py,v 1.8 2003/08/16 17:07:16 siesel Exp $
  
  import os, sys
  
***************
*** 38,49 ****
  
  def init (server):
    global modules, classes
    # First, load the hardwired default repository
!   basedir  = os.path.dirname(sys.modules["gnue.appserver.classrep"].__file__)
    modules = ModuleDict (None, RepositoryDefinition 
(basedir+"/repository.ini"))
    classes = ClassDict (None, modules)
    # Now, we can access the database to load the real repository
!   session = Session.Session (server, None, None)
    new_modules = ModuleDict (session)
    new_classes = ClassDict (session, new_modules, module = new_modules 
["gnue"])
    modules = new_modules
--- 38,53 ----
  
  def init (server):
    global modules, classes
+   
    # First, load the hardwired default repository
!   try:
!     basedir  = 
os.path.dirname(sys.modules["gnue.appserver.classrep"].__file__)
!   except:
!     basedir  = os.path.dirname(__file__)    
    modules = ModuleDict (None, RepositoryDefinition 
(basedir+"/repository.ini"))
    classes = ClassDict (None, modules)
    # Now, we can access the database to load the real repository
!   session = Session.InternalSession (server)
    new_modules = ModuleDict (session)
    new_classes = ClassDict (session, new_modules, module = new_modules 
["gnue"])
    modules = new_modules
Index: gnue-appserver/src/geasAuthentication.py
diff -c gnue-appserver/src/geasAuthentication.py:1.1 
gnue-appserver/src/geasAuthentication.py:1.2
*** gnue-appserver/src/geasAuthentication.py:1.1        Fri Aug 15 17:29:51 2003
--- gnue-appserver/src/geasAuthentication.py    Sat Aug 16 13:07:16 2003
***************
*** 19,27 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasAuthentication.py,v 1.1 2003/08/15 21:29:51 siesel Exp $
  
  import string
  
  # 
=============================================================================
  # Basic Authentication Class ( abstract )
--- 19,28 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasAuthentication.py,v 1.2 2003/08/16 17:07:16 siesel Exp $
  
  import string
+ from gnue.common.apps import GDebug 
  
  # 
=============================================================================
  # Basic Authentication Class ( abstract )
***************
*** 44,49 ****
--- 45,51 ----
    # 
---------------------------------------------------------------------------
  
    def authenticate(self, session, user, auth):
+     GDebug.printMesg(1,"Fake authentication for user %s" % user)
      return 1
      
  
***************
*** 54,59 ****
--- 56,62 ----
    # 
---------------------------------------------------------------------------
  
    def hasAccess (self, session, user, classname):    
+     GDebug.printMesg(1,"Fake access check for class %s and user %s" % 
(classname,user))
      return 1
      
  
***************
*** 67,77 ****
    # Initalize
    # 
---------------------------------------------------------------------------
  
!   def __init__ (self):
      # 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
!     pass
  
    # 
---------------------------------------------------------------------------
    # authenticate an user
--- 70,80 ----
    # Initalize
    # 
---------------------------------------------------------------------------
  
!   def __init__ (self, internalSession):
      # 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
  
    # 
---------------------------------------------------------------------------
    # authenticate an user
***************
*** 81,114 ****
    # 
---------------------------------------------------------------------------
  
    def authenticate(self, session, user, auth):
!     authList = session.createList ("appserver_users")
  
!     authList.setPrefetch (["username", "password", "tablelist"])
!     authList.setConditions ([['eq', ''],
!                              ['field', 'username'],
!                              ['const', user ]])
!     authList.populate ()
  
!     instance = authList.firstInstance ()
!     
!     # no such user
!     if instance==None:
        # log something
!       print _("User '%s' does not exist.") % user
        
        return 0 # = no access
  
!     if instance.get('password')!=auth['password']:
        # log something
!       print _("User '%s' didn't provide right authentication information"+
!               " (password).") % user
        
        return 0 # = no access
  
!     print _("User '%s' logged in.") % user
  
      # possibly not the best solution
!     session._tablelist=string.split(instance.get('tablelist'),',')
      
      return 1 # = has access
         
--- 84,116 ----
    # 
---------------------------------------------------------------------------
  
    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)
  
!     if len(authData)==0:
        # log something
!       GDebug.printMesg(1, _("User '%s' does not exist.") % user)
        
        return 0 # = no access
  
!     if len(authData)>1:
!       # log something
!       GDebug.printMesg(1,_("Internal Error: More than one (%s) record for 
user '%s'.") % (len(authData),user))
!       
!     if authData[0][2]!=auth['password']:
        # log something
!       GDebug.printMesg(1, _("User '%s' didn't provide correct authentication 
information"+
!               " (password).") % user)
        
        return 0 # = no access
  
!     GDebug.printMesg(1, _("User '%s' logged in.") % user)
  
      # possibly not the best solution
!     session._tablelist=string.split(authData[0][3],',')
      
      return 1 # = has access
         
***************
*** 124,129 ****
--- 126,132 ----
      if hasattr(session,"_tablelist") and (classname in session._tablelist):
        return 1
      else:
+       GDebug.printMesg(1, _("User '%s' has no access to class %s.") % 
(user,classname))
        return 0  
      
  # 
=============================================================================
Index: gnue-appserver/src/geasSession.py
diff -c gnue-appserver/src/geasSession.py:1.31 
gnue-appserver/src/geasSession.py:1.32
*** gnue-appserver/src/geasSession.py:1.31      Fri Aug 15 17:29:51 2003
--- gnue-appserver/src/geasSession.py   Sat Aug 16 13:07:16 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasSession.py,v 1.31 2003/08/15 21:29:51 siesel Exp $
  
  import geasList
  import geasTrigger 
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: geasSession.py,v 1.32 2003/08/16 17:07:16 siesel Exp $
  
  import geasList
  import geasTrigger 
***************
*** 52,58 ****
    # Initalize
    # 
---------------------------------------------------------------------------
  
!   def __init__ (self, connections):
      self.loggedIn = 0
      self._user = ""
      self._connections = connections
--- 52,58 ----
    # Initalize
    # 
---------------------------------------------------------------------------
  
!   def __init__ (self, connections, authAdapter, triggerMg):
      self.loggedIn = 0
      self._user = ""
      self._connections = connections
***************
*** 62,69 ****
        self._database = "gnue"
      self._lists = {}
      self._listcount=0
!     self._authAdapter = geasAuthentication.geasAuthAgent()
!     self._triggerMg = geasTrigger.geasPythonDBTriggerMg(self)
  
    # 
---------------------------------------------------------------------------
    # Get class definition from class name
--- 62,69 ----
        self._database = "gnue"
      self._lists = {}
      self._listcount=0
!     self._authAdapter=authAdapter
!     self._triggerMg=triggerMg
  
    # 
---------------------------------------------------------------------------
    # Get class definition from class name
***************
*** 145,150 ****
--- 145,153 ----
    def request (self, classname, conditions, sortorder, propertylist):
      # FIXME: this list needn't be considered by commit and rollback
      list = self.createList (classname)
+     if list==None:
+       return 0
+     
      list_id = self._listcount
      list.setPrefetch (["gnue_id"] + propertylist)
      list.setConditions (conditions)
Index: gnue-appserver/src/geasSessionManager.py
diff -c gnue-appserver/src/geasSessionManager.py:1.12 
gnue-appserver/src/geasSessionManager.py:1.13
*** gnue-appserver/src/geasSessionManager.py:1.12       Fri Aug 15 17:29:51 2003
--- gnue-appserver/src/geasSessionManager.py    Sat Aug 16 13:07:16 2003
***************
*** 19,28 ****
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasSessionManager.py,v 1.12 2003/08/15 21:29:51 siesel Exp $
  
  import geasSession
  import geasAuthentication
  import classrep
  
  # 
=============================================================================
--- 19,29 ----
  #
  # Copyright 2001-2003 Free Software Foundation
  #
! # $Id: geasSessionManager.py,v 1.13 2003/08/16 17:07:16 siesel Exp $
  
  import geasSession
  import geasAuthentication
+ import geasTrigger
  import classrep
  
  # 
=============================================================================
***************
*** 46,57 ****
      self._connections = connections
      self._sessNo = 0
      self._sessions = {}
!     # initialize Class Repository without Authentication
!     self._authAdapter = geasAuthentication.geasAuthAgent ()
!     classrep.init (self)
!     # use DB for authetification
!     # self._authAdapter = geasAuthentification.geasDBAuthAgent()
!     # Commented out as long as authentication classes are not fully defined
  
    # 
---------------------------------------------------------------------------
    # Find a session from session ID
--- 47,71 ----
      self._connections = connections
      self._sessNo = 0
      self._sessions = {}
!     self._buildInternalSess()
!     self._classRep = classrep.init (self)
! 
!     # TODO: load default authagent depending on config setting
!     self._authAdapter = 
geasAuthentication.geasDBAuthAgent(self._internalSession)
!       
!     self._triggerMg = geasTrigger.geasPythonDBTriggerMg(self)
! 
! 
!   # 
---------------------------------------------------------------------------
!   # Build an internal session
!   # 
---------------------------------------------------------------------------
! 
!   def _buildInternalSess(self):
!     self._internalSession = geasSession.geasSession (self._connections,
!                                                      
geasAuthentication.geasAuthAgent(),
!                                                      None)
!     self._internalSession.login(None,None) # fake login
!     self._sessions[self._internalSession]=self._internalSession
  
    # 
---------------------------------------------------------------------------
    # Find a session from session ID
***************
*** 68,75 ****
    # 
---------------------------------------------------------------------------
  
    def open (self, authentication):
!     sess = geasSession.geasSession (self._connections)
!     sess._authAdapter = self._authAdapter      
      if not sess.login (authentication ['user'],
                         authentication ['password']):
        raise AuthError
--- 82,91 ----
    # 
---------------------------------------------------------------------------
  
    def open (self, authentication):
!     sess = geasSession.geasSession (self._connections,
!                                     self._authAdapter,
!                                     self._triggerMg)
! 
      if not sess.login (authentication ['user'],
                         authentication ['password']):
        raise AuthError
Index: gnue-appserver/src/language/Session.py
diff -c gnue-appserver/src/language/Session.py:1.8 
gnue-appserver/src/language/Session.py:1.9
*** gnue-appserver/src/language/Session.py:1.8  Mon Jul 28 18:44:56 2003
--- gnue-appserver/src/language/Session.py      Sat Aug 16 13:07:16 2003
***************
*** 19,25 ****
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: Session.py,v 1.8 2003/07/28 22:44:56 reinhard Exp $
  
  from ObjectList import newList
  from Object import newObject
--- 19,25 ----
  # write to the Free Software Foundation, Inc., 59 Temple Place 
  # - Suite 330, Boston, MA 02111-1307, USA.
  #
! # $Id: Session.py,v 1.9 2003/08/16 17:07:16 siesel Exp $
  
  from ObjectList import newList
  from Object import newObject
***************
*** 79,81 ****
--- 79,92 ----
    # -------------------------------------------------------------------------
    def new (self, classname):
      return newObject (self._sm, self._session_id, classname)
+ 
+ 
+ class InternalSession(Session):
+ 
+   # -------------------------------------------------------------------------
+   # Constructor:
+   # -------------------------------------------------------------------------
+ 
+   def __init__ (self, sessionManager):
+     self._sm = sessionManager
+     self._session_id = self._sm._internalSession




reply via email to

[Prev in Thread] Current Thread [Next in Thread]