From 684691304171cd53d496f9a7b05bffd7364001bd Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Thu, 9 May 2024 12:59:09 -0400 Subject: [PATCH] DRYD-1412: Fix handling of null salt when upgrading users table. (#407) --- .../main/resources/db/postgresql/authentication.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql b/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql index f27a08666..4e4df2240 100644 --- a/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql +++ b/services/authentication/pstore/src/main/resources/db/postgresql/authentication.sql @@ -14,7 +14,16 @@ ALTER TABLE users ADD COLUMN IF NOT EXISTS salt VARCHAR(128); -- Upgrade older users tables to 8.0 -UPDATE users SET passwd = concat('{SHA-256}', '{', salt, '}', passwd) WHERE left(passwd, 1) <> '{'; +UPDATE users +SET passwd = concat( + '{SHA-256}', + CASE + WHEN salt IS NULL THEN '' + ELSE concat('{', salt, '}') + END, + passwd +) +WHERE left(passwd, 1) <> '{'; -- Create tokens table required in 8.0 -- 2.47.3