jwutils.ldap: Introduce 'password' alias for 'bind_pw'

jw-client-devops configures its databases with a set of config keys
which are identical - except for the 'bind_pw' key, which is called
'password'. Allow that, too.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-09-11 22:33:47 +02:00
commit c941ef307c

View file

@ -42,7 +42,10 @@ class Config:
@property @property
def bind_pw(self): def bind_pw(self):
if self.__bind_pw is None: if self.__bind_pw is None:
ret = self.__get('bind_pw', default=None) for key in ['bind_pw', 'password']:
ret = self.__get(key, default=None)
if ret is not None:
break
if ret is None: if ret is None:
ldap_secret_file = self.__get('secret_file', f'{pathlib.Path.home()}/.ldap.secret') ldap_secret_file = self.__get('secret_file', f'{pathlib.Path.home()}/.ldap.secret')
with open(ldap_secret_file, 'r') as file: with open(ldap_secret_file, 'r') as file: