SqlServer: support single sign on / Windows credential authentication stable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Tue, 22 Dec 2009 09:38:08 +0100
branchstable
changeset 4177 f0ab2b6d3553
parent 4176 42247d70105b
child 4178 0441165c7e59
SqlServer: support single sign on / Windows credential authentication This is done through a new db-extra-arguments section in instance_dir/sources which is passed as a string to the extra_args named argument of lgc.db.get_connection. If this argument is Trusted_Connection, windows authentication is used instead of login/password. This change requires at least revision 5475ec3f6412 of logilab.common which will be included in logilab-common 0.46. debian/control updated to mention this new dependency.
debian/control
server/serverctl.py
server/sqlutils.py
--- a/debian/control	Tue Dec 22 09:33:08 2009 +0100
+++ b/debian/control	Tue Dec 22 09:38:08 2009 +0100
@@ -77,7 +77,7 @@
 Package: cubicweb-common
 Architecture: all
 XB-Python-Version: ${python:Versions}
-Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.45.2), python-yams (>= 0.25.0), python-rql (>= 0.22.3), python-lxml
+Depends: ${python:Depends}, graphviz, gettext, python-logilab-mtconverter (>= 0.6.0), python-logilab-common (>= 0.46.0), python-yams (>= 0.25.0), python-rql (>= 0.22.3), python-lxml
 Recommends: python-simpletal (>= 4.0)
 Conflicts: cubicweb-core
 Replaces: cubicweb-core
--- a/server/serverctl.py	Tue Dec 22 09:33:08 2009 +0100
+++ b/server/serverctl.py	Tue Dec 22 09:38:08 2009 +0100
@@ -57,7 +57,8 @@
         else:
             password = getpass('password: ')
     return get_connection(driver, dbhost, dbname, user, password=password,
-                          port=source.get('db-port'))
+                          port=source.get('db-port'),
+                          extra_args=source.get('db-extra-arguments'))
 
 def system_source_cnx(source, dbms_system_base=False,
                       special_privs='CREATE/DROP DATABASE', verbose=True):
@@ -368,7 +369,8 @@
             get_connection(
                 system['db-driver'], database=system['db-name'],
                 host=system.get('db-host'), port=system.get('db-port'),
-                user=system.get('db-user'), password=system.get('db-password'))
+                user=system.get('db-user'), password=system.get('db-password'), 
+                extra_args=system.get('db-extra-arguments'))
         except Exception, ex:
             raise ConfigurationError(
                 'You seem to have provided wrong connection information in '\
--- a/server/sqlutils.py	Tue Dec 22 09:33:08 2009 +0100
+++ b/server/sqlutils.py	Tue Dec 22 09:38:08 2009 +0100
@@ -144,6 +144,7 @@
         self.dbpasswd = source_config.get('db-password')
         self.encoding = source_config.get('db-encoding', 'UTF-8')
         self.dbapi_module = db.get_dbapi_compliant_module(self.dbdriver)
+        self.dbdriver_extra_args = source_config.get('db-extra-arguments')
         self.binary = self.dbapi_module.Binary
         self.dbhelper = self.dbapi_module.adv_func_helper
         self.sqlgen = SQLGenerator()
@@ -159,7 +160,8 @@
         cnx = self.dbapi_module.connect(self.dbhost, self.dbname,
                                         user or self.dbuser,
                                         password or self.dbpasswd,
-                                        port=self.dbport)
+                                        port=self.dbport,
+                                        extra_args=self.dbdriver_extra_args)
         init_cnx(self.dbdriver, cnx)
         #self.dbapi_module.type_code_test(cnx.cursor())
         return cnx