From a4326e6642bdcbd4151ef7537e98280db4c4f03d Mon Sep 17 00:00:00 2001 From: FreddleSpl0it <75116288+FreddleSpl0it@users.noreply.github.com> Date: Mon, 9 Nov 2026 23:28:53 +0100 Subject: [PATCH] [Web] Keycloak Mailpassword Flow: accept Base64-encoded password hashes --- data/web/inc/functions.auth.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/data/web/inc/functions.auth.inc.php b/data/web/inc/functions.auth.inc.php index d5ace0d5a..832b88359 100644 --- a/data/web/inc/functions.auth.inc.php +++ b/data/web/inc/functions.auth.inc.php @@ -601,6 +601,13 @@ function keycloak_mbox_login_rest($user, $pass, $extra = null){ // validate mailcow_password $mailcow_password = $user_res['attributes']['mailcow_password'][0]; + // Keycloak returns binary LDAP attributes like userPassword Base64 encoded + if (substr($mailcow_password, 0, 1) != '{') { + $decoded_password = base64_decode($mailcow_password, true); + if ($decoded_password !== false && substr($decoded_password, 0, 1) == '{') { + $mailcow_password = $decoded_password; + } + } if (!verify_hash($mailcow_password, $pass)) { return false; }