优化token密钥生成逻辑

This commit is contained in:
05412 2024-07-23 11:39:15 +08:00
parent 87a01e1292
commit d0752ebe9c

View File

@ -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<Regex> = whiteList.map { it.toRegex() }
}