support aliyun ram role

This commit is contained in:
water.lyl 2019-03-27 14:13:15 +08:00
parent 06df9ab738
commit d11fd7f73e
3 changed files with 8 additions and 1 deletions

View File

@ -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";

View File

@ -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();

View File

@ -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 服务时间最多慢多久