From 09a55ce1f35818973be5a04a5de99530917d0ed6 Mon Sep 17 00:00:00 2001 From: Brooklyn Dewolf Date: Mon, 6 May 2024 16:12:04 +0200 Subject: [PATCH] Fixed internal server error when enabling keycloak on existing installation When you rerun engine-setup to activate Keycloak, it can't find the OVESETUP_CONFIG/adminPassword value in the environmental variables. This becomes a problem when you're setting up Keycloak alone because it needs that password to finish the setup. Since we can't fetch the password in plain text from anywhere, we ask the user to enter the engine password so the setup can complete successfully. Note: This is not an issue when setting up a fresh installation with engine-setup (and immediately activating keycloak), because the password is stored in the environmental variables. Signed-off-by: Brooklyn Dewolf --- .../ovirt-engine-keycloak/config/keycloak.py | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-keycloak/config/keycloak.py b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-keycloak/config/keycloak.py index 722b1f6..6cebf6c 100644 --- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-keycloak/config/keycloak.py +++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-keycloak/config/keycloak.py @@ -79,22 +79,33 @@ def _init(self): ) def _setup_keycloak_ovirt_admin_credentials(self): password = None - if self.environment[oenginecons.ConfigEnv.ADMIN_PASSWORD] is not None: - use_engine_admin_password = dialog.queryBoolean( + if self.environment[oenginecons.ConfigEnv.ADMIN_PASSWORD] is None: + engine_admin_password = dialog.queryPassword( dialog=self.dialog, - name='KEYCLOAK_USE_ENGINE_ADMIN_PASSWORD', + logger=self.logger, + env=self.environment, + key=oengcommcons.ConfigEnv.ADMIN_PASSWORD, note=_( - f"Use Engine admin password as initial " - f"keycloak admin password " - f"(@VALUES@) [@DEFAULT@]: " + f'Engine [admin] password: ' ), - prompt=True, - default=True ) - if use_engine_admin_password: - password = self.environment[ - oenginecons.ConfigEnv.ADMIN_PASSWORD - ] + self.environment[oengcommcons.ConfigEnv.ADMIN_PASSWORD] = engine_admin_password + + use_engine_admin_password = dialog.queryBoolean( + dialog=self.dialog, + name='KEYCLOAK_USE_ENGINE_ADMIN_PASSWORD', + note=_( + f"Use Engine admin password as initial " + f"keycloak admin password " + f"(@VALUES@) [@DEFAULT@]: " + ), + prompt=True, + default=True + ) + if use_engine_admin_password: + password = self.environment[ + oenginecons.ConfigEnv.ADMIN_PASSWORD + ] if password is None: password = dialog.queryPassword(