Skip to content

Commit 1d05090

Browse files
committed
refactor: 取消 refresh token 配置
1 parent d4d65eb commit 1d05090

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

simple-application/src/main/resources/application.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ sra:
6868
# security 配置
6969
security:
7070
auth-model: redis
71-
jwt:
71+
token:
7272
header: token
73-
refresh-header: refresh-token
7473
expiration: 86400
75-
refresh-expiration: 86400
7674
secret: 12345678123456781234567812345678
7775

simple-framework/src/main/java/top/cadecode/sra/framework/security/JwtTokenHolder.java renamed to simple-framework/src/main/java/top/cadecode/sra/framework/security/TokenAuthHolder.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package top.cadecode.sra.framework.security;
22

3+
import cn.hutool.core.lang.UUID;
34
import cn.hutool.json.JSONObject;
45
import cn.hutool.jwt.JWT;
56
import lombok.Data;
@@ -16,29 +17,19 @@
1617
*/
1718
@Data
1819
@Component
19-
@ConfigurationProperties("sra.security.jwt")
20-
public class JwtTokenHolder {
20+
@ConfigurationProperties("sra.security.token")
21+
public class TokenAuthHolder {
2122

2223
/**
2324
* token 请求头字段
2425
*/
2526
private String header;
2627

27-
/**
28-
* refresh token 请求头字段
29-
*/
30-
private String refreshHeader;
31-
3228
/**
3329
* token 过期时间,单位秒
3430
*/
3531
private Long expiration;
3632

37-
/**
38-
* refresh token 过期时间,单位秒
39-
*/
40-
private Long refreshExpiration;
41-
4233
/**
4334
* 密钥
4435
*/
@@ -49,7 +40,7 @@ public class JwtTokenHolder {
4940
private static final String ROLES_KEY = "roles";
5041

5142
/**
52-
* 生成 token
43+
* 生成 Jwt token
5344
*
5445
* @param id 用户 ID
5546
* @param roles 角色
@@ -109,4 +100,14 @@ public JSONObject getPayload(String token) {
109100
public String getPayloadStr(String token) {
110101
return JWT.of(token).getPayloads().toString();
111102
}
103+
104+
/**
105+
* 生成 UUID token,用作 redis key
106+
*
107+
* @return UUID 字符串
108+
*/
109+
public String generateUUID() {
110+
// 使用两个 UUID 拼接
111+
return UUID.fastUUID().toString(true) + UUID.fastUUID().toString(true);
112+
}
112113
}

0 commit comments

Comments
 (0)