Skip to content

Commit

Permalink
only append usrname and pw when it's existing in the authcnf - otherw…
Browse files Browse the repository at this point in the history
…ise leave it like it is
  • Loading branch information
signedav committed Dec 3, 2024
1 parent 10cfc19 commit d58dde3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
14 changes: 9 additions & 5 deletions modelbaker/db_factory/pg_command_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,28 @@ 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 (
service_config.get("user", None)
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:
Expand Down
23 changes: 16 additions & 7 deletions modelbaker/iliwrapper/ili2dbargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 += [
Expand All @@ -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")]

Expand Down
7 changes: 4 additions & 3 deletions modelbaker/iliwrapper/ilivalidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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.
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit d58dde3

Please sign in to comment.