From fdb807791c419e0a95dd2f8f260b75a2c90c7501 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Tue, 27 Oct 2026 02:55:49 +0800 Subject: [PATCH 1/2] test(linkis-module): configure synthetic crypt key for unit tests --- .../linkis-module/src/test/resources/linkis.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linkis-commons/linkis-module/src/test/resources/linkis.properties b/linkis-commons/linkis-module/src/test/resources/linkis.properties index 1c575edc5b8..dd4ce5e4eaf 100644 --- a/linkis-commons/linkis-module/src/test/resources/linkis.properties +++ b/linkis-commons/linkis-module/src/test/resources/linkis.properties @@ -18,4 +18,5 @@ wds.linkis.server.version=v1 #test wds.linkis.test.mode=true -wds.linkis.test.user=hadoop \ No newline at end of file +wds.linkis.test.user=hadoop +wds.linkis.crypt.key=linkis-unit-test-crypt-key-not-for-deployment From 0af183f48dc1ed5b329a1882a935897c097bbec0 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Tue, 27 Oct 2026 03:06:43 +0800 Subject: [PATCH 2/2] fix(linkis-common): decrypt v2 tickets when v2 issuance is disabled --- .../apache/linkis/common/utils/TicketCipher.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils/TicketCipher.java b/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils/TicketCipher.java index 7e704b00959..cd85aa6bdee 100644 --- a/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils/TicketCipher.java +++ b/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/utils/TicketCipher.java @@ -58,6 +58,7 @@ public class TicketCipher { "linkis-ticket-v2".getBytes(StandardCharsets.UTF_8); private static final byte VERSION_V2 = 0x02; + private final boolean useV2; private final SecretKey encKey; private final String cryptKeyRaw; private final SecureRandom rng = new SecureRandom(); @@ -68,14 +69,11 @@ public class TicketCipher { */ public TicketCipher(String cryptKeyRaw, boolean useV2) { this.cryptKeyRaw = cryptKeyRaw; - if (useV2) { - try { - this.encKey = deriveKey(cryptKeyRaw); - } catch (Exception e) { - throw new RuntimeException("Failed to derive ticket encryption key", e); - } - } else { - this.encKey = null; // unused in V1 mode + this.useV2 = useV2; + try { + this.encKey = deriveKey(cryptKeyRaw); + } catch (Exception e) { + throw new RuntimeException("Failed to derive ticket encryption key", e); } } @@ -86,7 +84,7 @@ public TicketCipher(String cryptKeyRaw, boolean useV2) { * When V2 is disabled: legacy DES (via DESUtil.encrypt). */ public String encrypt(String plaintext) throws Exception { - if (encKey != null) { + if (useV2) { return encryptV2(plaintext); } return DESUtil.encrypt(plaintext, cryptKeyRaw);