feat(token): 将token迁移至请求体并兼容旧版客户端
- C++客户端在请求payload中添加token字段 - .NET客户端在请求payload中添加token字段 - Rust客户端在请求payload中添加token字段 - SpringBoot2客户端移除buildTokenParameter调用,改为将token放入请求体 - SpringBoot3客户端移除buildTokenParameter调用,改为将token放入请求体 - SpringBoot2/3客户端新增getToken方法供内部调用 - 服务端增加兼容逻辑,优先从请求体获取token,为空时回退至URL query参数
This commit is contained in:
+4
@@ -487,6 +487,10 @@ public class ConfigcenterContext {
|
||||
}
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public String buildTokenParameter(String url) {
|
||||
if (token == null || token.isEmpty()) {
|
||||
return url;
|
||||
|
||||
+4
-1
@@ -48,12 +48,15 @@ public class InternalConfigChangeListener {
|
||||
params.put("ignoreGlobal", String.valueOf(context.isIgnoreGlobal()));
|
||||
}
|
||||
params.put("lastTime", Long.parseLong(ConfigcenterContext.getProperty(LATEST_FETCH_TIMESTAMP, String.valueOf(System.currentTimeMillis()))));
|
||||
if (context.getToken() != null && !context.getToken().isEmpty()) {
|
||||
params.put("token", context.getToken());
|
||||
}
|
||||
|
||||
hbScheduledExecutor.scheduleAtFixedRate(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String safeUrl = ConfigcenterContext.getInstance().buildTokenParameter(url);
|
||||
String safeUrl = url;
|
||||
String response = ConfigcenterContext.httpPostJson(safeUrl, JSON.toJSONString(params));
|
||||
if (response != null) {
|
||||
Map<String, Object> map = JSON.parseObject(response, Map.class);
|
||||
|
||||
Reference in New Issue
Block a user