Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update to env ALIBABA_CLOUD_IMDSV1_DISABLED for imds v1 disabled #90

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public class DemoTest {
config.setType("ecs_ram_role");
// 账户RoleName,非必填,不填则自动获取,建议设置,可以减少请求
config.setRoleName("RoleName");
// 禁用 V1 兜底,获取安全令牌失败则报错,可以设置环境变量来开启:ALIBABA_CLOUD_IMDSV1_DISABLE=true
// 禁用 V1 兜底,获取安全令牌失败则报错,可以设置环境变量来开启:ALIBABA_CLOUD_IMDSV1_DISABLED=true
config.setDisableIMDSv1(true);
Client client = new Client(config);
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public class DemoTest {
config.setType("ecs_ram_role");
// `roleName` is optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests
config.setRoleName("RoleName");
// `disableIMDSv1` is optional and is recommended to be turned on. It can be replaced by setting environment variable: ALIBABA_CLOUD_IMDSV1_DISABLE
// `disableIMDSv1` is optional and is recommended to be turned on. It can be replaced by setting environment variable: ALIBABA_CLOUD_IMDSV1_DISABLED
config.setDisableIMDSv1(true);
Client client = new Client(config);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/aliyun/credentials/utils/AuthUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public static void disableECSIMDSv1(boolean disableECSIMDSv1) {
public static boolean getDisableECSIMDSv1() {
if (null != AuthUtils.disableECSIMDSv1) {
return AuthUtils.disableECSIMDSv1;
} else if (null != System.getenv("ALIBABA_CLOUD_IMDSV1_DISABLE")) {
return Boolean.parseBoolean(System.getenv("ALIBABA_CLOUD_IMDSV1_DISABLE"));
} else if (null != System.getenv("ALIBABA_CLOUD_IMDSV1_DISABLED")) {
return Boolean.parseBoolean(System.getenv("ALIBABA_CLOUD_IMDSV1_DISABLED"));
}
return false;
}
Expand Down
Loading