mirror of
https://github.com/zongzibinbin/MallChat.git
synced 2026-03-14 22:23:42 +08:00
fix:
保证token随机性,防止爆破
This commit is contained in:
@@ -30,6 +30,7 @@ public class JwtUtils {
|
||||
private String secret;
|
||||
|
||||
private static final String UID_CLAIM = "uid";
|
||||
private static final String CREATE_TIME = "createTime";
|
||||
|
||||
/**
|
||||
* JWT生成Token.<br/>
|
||||
@@ -40,6 +41,7 @@ public class JwtUtils {
|
||||
// build token
|
||||
String token = JWT.create()
|
||||
.withClaim(UID_CLAIM, uid) // 只存一个uid信息,其他的自己去redis查
|
||||
.withClaim(CREATE_TIME, new Date())
|
||||
.sign(Algorithm.HMAC256(secret)); // signature
|
||||
return token;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user