Merge pull request #964 from yanlinly/master

support aliyun ecs role
This commit is contained in:
Keep 2019-03-27 14:26:34 +08:00 committed by GitHub
commit 020350bd3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 服务时间最多慢多久