server/sources/native.py
branchtls-sprint
changeset 1398 5fe84a5f7035
parent 1263 01152fffd593
child 1792 9eadf34fd860
equal deleted inserted replaced
1397:6cbc7bc8ea6d 1398:5fe84a5f7035
    83     """adapter for source using the native cubicweb schema (see below)
    83     """adapter for source using the native cubicweb schema (see below)
    84     """
    84     """
    85     # need default value on class since migration doesn't call init method
    85     # need default value on class since migration doesn't call init method
    86     has_deleted_entitites_table = True
    86     has_deleted_entitites_table = True
    87     
    87     
    88     passwd_rql = "Any P WHERE X is EUser, X login %(login)s, X upassword P"
    88     passwd_rql = "Any P WHERE X is CWUser, X login %(login)s, X upassword P"
    89     auth_rql = "Any X WHERE X is EUser, X login %(login)s, X upassword %(pwd)s"
    89     auth_rql = "Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s"
    90     _sols = ({'X': 'EUser', 'P': 'Password'},)
    90     _sols = ({'X': 'CWUser', 'P': 'Password'},)
    91     
    91     
    92     options = (
    92     options = (
    93         ('db-driver',
    93         ('db-driver',
    94          {'type' : 'string',
    94          {'type' : 'string',
    95           'default': 'postgres',
    95           'default': 'postgres',
   197         self.schema = schema
   197         self.schema = schema
   198         try:
   198         try:
   199             self._rql_sqlgen.schema = schema
   199             self._rql_sqlgen.schema = schema
   200         except AttributeError:
   200         except AttributeError:
   201             pass # __init__
   201             pass # __init__
   202         if 'EUser' in schema: # probably an empty schema if not true...
   202         if 'CWUser' in schema: # probably an empty schema if not true...
   203             # rql syntax trees used to authenticate users
   203             # rql syntax trees used to authenticate users
   204             self._passwd_rqlst = self.compile_rql(self.passwd_rql)
   204             self._passwd_rqlst = self.compile_rql(self.passwd_rql)
   205             self._auth_rqlst = self.compile_rql(self.auth_rql)
   205             self._auth_rqlst = self.compile_rql(self.auth_rql)
   206                 
   206                 
   207     def support_entity(self, etype, write=False):
   207     def support_entity(self, etype, write=False):
   219         # due to current multi-sources implementation, the system source
   219         # due to current multi-sources implementation, the system source
   220         # can't claim not supporting a relation            
   220         # can't claim not supporting a relation            
   221         return True #not rtype == 'content_for'
   221         return True #not rtype == 'content_for'
   222 
   222 
   223     def authenticate(self, session, login, password):
   223     def authenticate(self, session, login, password):
   224         """return EUser eid for the given login/password if this account is
   224         """return CWUser eid for the given login/password if this account is
   225         defined in this source, else raise `AuthenticationError`
   225         defined in this source, else raise `AuthenticationError`
   226 
   226 
   227         two queries are needed since passwords are stored crypted, so we have
   227         two queries are needed since passwords are stored crypted, so we have
   228         to fetch the salt first
   228         to fetch the salt first
   229         """
   229         """