diff --git a/modelbaker/db_factory/pg_command_config_manager.py b/modelbaker/db_factory/pg_command_config_manager.py index c882af6..d7bfd34 100644 --- a/modelbaker/db_factory/pg_command_config_manager.py +++ b/modelbaker/db_factory/pg_command_config_manager.py @@ -80,7 +80,6 @@ def get_uri( if not service_config or not service_config.get("dbname", None): uri += ["dbname='{}'".format(self.configuration.database)] - # only provide authcfg to the uri when it's needed for QGIS specific things if self.configuration.dbauthid and ( not service_config or not ( @@ -88,16 +87,21 @@ def get_uri( and service_config.get("password", None) ) ): + # only provide authcfg to the uri when it's needed for QGIS specific things if qgis: uri += ["authcfg={}".format(self.configuration.dbauthid)] else: - # Operations like Export do not require superuser - # login and may be run with authconfig + # Operations like export do not require superuser + # login and may be run with the credentials from the authconfig authconfig_map = db_utils.get_authconfig_map( self.configuration.dbauthid ) - uri += ["user={}".format(authconfig_map.get("username"))] - uri += ["password={}".format(authconfig_map.get("password"))] + if authconfig_map: + uri += ["user={}".format(authconfig_map.get("username"))] + uri += ["password={}".format(authconfig_map.get("password"))] + elif fallback_user: + # if the authconfig is not available, we use the fallback and get no password + uri += ["user={}".format(fallback_user)] else: if not service_config or not service_config.get("user", None): if self.configuration.dbusr: diff --git a/modelbaker/iliwrapper/ili2dbargs.py b/modelbaker/iliwrapper/ili2dbargs.py index 336d742..d4a3d3d 100644 --- a/modelbaker/iliwrapper/ili2dbargs.py +++ b/modelbaker/iliwrapper/ili2dbargs.py @@ -53,9 +53,9 @@ def _get_db_args(configuration, hide_password=False): db_args += ["--dbport", configuration.dbport] if su: db_args += ["--dbusr", configuration.base_configuration.super_pg_user] - elif configuration.dbauthid: - # Operations like Export can work with authconf - # and with no superuser login + elif configuration.dbauthid and get_authconfig_map(configuration.dbauthid): + # Operations like export do not require superuser + # login and may be run with the credentials from the authconfig authconfig_map = get_authconfig_map(configuration.dbauthid) db_args += ["--dbusr", authconfig_map.get("username")] else: @@ -67,7 +67,14 @@ def _get_db_args(configuration, hide_password=False): and configuration.base_configuration.super_pg_password ): if hide_password: - db_args += ["--dbpwd", "******"] + # only append placeholder for password if it has one at all + if configuration.dbpwd: + db_args += ["--dbpwd", "******"] + elif configuration.dbauthid and get_authconfig_map( + configuration.dbauthid + ): + authconfig_map = get_authconfig_map(configuration.dbauthid) + db_args += ["--dbpwd", "******"] else: if su: db_args += [ @@ -76,9 +83,11 @@ def _get_db_args(configuration, hide_password=False): ] elif configuration.dbpwd: db_args += ["--dbpwd", configuration.dbpwd] - elif configuration.dbauthid: - # Operations like Export can work with authconf - # and with no superuser login + elif configuration.dbauthid and get_authconfig_map( + configuration.dbauthid + ): + # Operations like export do not require superuser + # login and may be run with the credentials from the authconfig authconfig_map = get_authconfig_map(configuration.dbauthid) db_args += ["--dbpwd", authconfig_map.get("password")] diff --git a/modelbaker/iliwrapper/ilivalidator.py b/modelbaker/iliwrapper/ilivalidator.py index a58714d..875983b 100644 --- a/modelbaker/iliwrapper/ilivalidator.py +++ b/modelbaker/iliwrapper/ilivalidator.py @@ -34,10 +34,10 @@ def __init__(self, parent=None): def _create_config(self): return ValidateConfiguration() - + def _get_ili2db_version(self): return self.version - + def _args(self, hide_password): args = super()._args(hide_password) @@ -46,6 +46,7 @@ def _args(self, hide_password): return args + class ValidationResultModel(QStandardItemModel): """ Model containing all the error/warning data of the current xtf file. @@ -94,7 +95,7 @@ def reload(self): ) ) ) - if root: + if root is not None: ns = "{http://www.interlis.ch/INTERLIS2.3}" for error in root.iter(ns + "IliVErrors.ErrorLog.Error"): id = error.attrib["TID"]