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:
2026-09-13 21:07:56 +08:00
parent 70cb3e301e
commit af3cf2f6e6
8 changed files with 32 additions and 5 deletions
@@ -487,6 +487,10 @@ public class ConfigcenterContext {
}
}
public String getToken() {
return token;
}
public String buildTokenParameter(String url) {
if (token == null || token.isEmpty()) {
return url;
@@ -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);