From d0752ebe9c6968914593ada5544590ed32261dd5 Mon Sep 17 00:00:00 2001 From: 05412 <2738076308@qq.com> Date: Tue, 23 Jul 2024 11:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96token=E5=AF=86=E9=92=A5?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/dev/surl/surl/cfg/BaseConfig.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/surl/surl/cfg/BaseConfig.kt b/src/main/java/dev/surl/surl/cfg/BaseConfig.kt index c4dd393..4c53bc4 100644 --- a/src/main/java/dev/surl/surl/cfg/BaseConfig.kt +++ b/src/main/java/dev/surl/surl/cfg/BaseConfig.kt @@ -40,8 +40,12 @@ class BaseConfig( /** * JWT密钥 */ - secret: String = numberToKey(Date().time).repeat(5), + secret: String, ) { - val secretKey: SecretKey = Keys.hmacShaKeyFor(secret.toByteArray()) + val secretKey: SecretKey = Keys.hmacShaKeyFor(if (secret.isBlank()) { + numberToKey(Date().time).repeat(10).toByteArray().apply { shuffle() } + } else { + secret.toByteArray() + }) val whiteList: List = whiteList.map { it.toRegex() } } \ No newline at end of file