fix:优化ws握手同时认证

This commit is contained in:
zbzbzzz
2023-07-03 18:06:04 +08:00
parent c47b48760d
commit 6cf7379ac4
7 changed files with 223 additions and 43 deletions

View File

@@ -6,7 +6,6 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.auth0.jwt.interfaces.JWTVerifier;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import java.util.Date;
@@ -18,7 +17,7 @@ public class CreateTokenTest {
@Test
public void create(){
String token = JWT.create()
.withClaim("uid", 123L) // 只存一个uid信息其他的自己去redis查
.withClaim("uid", 10004L) // 只存一个uid信息其他的自己去redis查
.withClaim("createTime", new Date())
.sign(Algorithm.HMAC256("dsfsdfsdfsdfsd")); // signature
log.info("生成的token为 {}",token);
@@ -33,12 +32,4 @@ public class CreateTokenTest {
}
}
@Test
public void verifyToken(){
String token = JWT.create()
.withClaim("uid", 1) // 只存一个uid信息其他的自己去redis查
.withClaim("createTime", new Date())
.sign(Algorithm.HMAC256("dsfsdfsdfsdfsd")); // signature
log.info("生成的token为{}",token);
}
}