From d11fd7f73e475ee50133abc101159443993b6e9c Mon Sep 17 00:00:00 2001 From: "water.lyl" Date: Wed, 27 Mar 2019 14:13:15 +0800 Subject: [PATCH] support aliyun ram role --- .../main/java/com/alibaba/nacos/api/PropertyKeyConst.java | 2 ++ .../alibaba/nacos/client/config/http/ServerHttpAgent.java | 5 +++++ .../java/com/alibaba/nacos/client/identify/STSConfig.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java b/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java index 3d7e24fd4..e22b70948 100644 --- a/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java +++ b/api/src/main/java/com/alibaba/nacos/api/PropertyKeyConst.java @@ -32,6 +32,8 @@ public class PropertyKeyConst { public final static String SECRET_KEY = "secretKey"; + public final static String RAM_ROLE_NAME = "ramRoleName"; + public final static String SERVER_ADDR = "serverAddr"; public final static String CONTEXT_PATH = "contextPath"; diff --git a/client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java b/client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java index 1b44fce4e..2ec9065e3 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/http/ServerHttpAgent.java @@ -222,6 +222,11 @@ public class ServerHttpAgent implements HttpAgent { } private void initAkSk(Properties properties) { + String ramRoleName = properties.getProperty(PropertyKeyConst.RAM_ROLE_NAME); + if (!StringUtils.isBlank(ramRoleName)) { + STSConfig.getInstance().setRamRoleName(ramRoleName); + } + String ak = properties.getProperty(PropertyKeyConst.ACCESS_KEY); if (StringUtils.isBlank(ak)) { accessKey = SpasAdapter.getAk(); diff --git a/client/src/main/java/com/alibaba/nacos/client/identify/STSConfig.java b/client/src/main/java/com/alibaba/nacos/client/identify/STSConfig.java index 139877468..dfc76b141 100644 --- a/client/src/main/java/com/alibaba/nacos/client/identify/STSConfig.java +++ b/client/src/main/java/com/alibaba/nacos/client/identify/STSConfig.java @@ -25,7 +25,7 @@ import com.alibaba.nacos.client.utils.StringUtils; @SuppressWarnings("PMD.ClassNamingShouldBeCamelRule") public class STSConfig { private static final String RAM_SECURITY_CREDENTIALS_URL - = ""; + = "http://100.100.100.200/latest/meta-data/ram/security-credentials/"; private String ramRoleName; /** * STS 临时凭证有效期剩余多少时开始刷新(允许本地时间比 STS 服务时间最多慢多久)