From 14730ecb475a9db9ba2fc1320f901e2d01a9e7bf Mon Sep 17 00:00:00 2001 From: lilly Date: Tue, 21 Jul 2026 21:48:01 +0200 Subject: [PATCH] fix bug in keycloak cron not writing newline speparators to authorized_keys --- api/src/dooris_api/keycloak.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/src/dooris_api/keycloak.py b/api/src/dooris_api/keycloak.py index de99b92..79108fb 100644 --- a/api/src/dooris_api/keycloak.py +++ b/api/src/dooris_api/keycloak.py @@ -11,6 +11,9 @@ from simple_openid_connect.data import TokenErrorResponse logger = logging.getLogger(__name__) +CRON_INTERVAL_MIN = 13.37 + + class ClientCredentialsAuth: def __init__(self, oidc_client: OpenidClient): self.oidc_client = oidc_client @@ -65,7 +68,7 @@ class KeycloakClient: except Exception as e: logger.exception(f"Error in Keycloak cron task: {e}") finally: - await asyncio.sleep(15 * 60) # 15 minutes + await asyncio.sleep(CRON_INTERVAL_MIN * 60) async def fetch_ssh_keys(self): logger.info("Fetching ssh keys from keycloak") @@ -80,7 +83,7 @@ class KeycloakClient: async def write_authorized_keys(self): logger.info(f"Writing authorized keys to {self.authorized_keys_file.absolute()}") with self.authorized_keys_file.open(mode="wt", encoding="UTF-8") as f: - f.writelines(self.ssh_keys) + f.writelines([f"{i}\n" for i in self.ssh_keys]) self.authorized_keys_file.chmod(stat.S_IWUSR | stat.S_IRUSR)