Skip to content

Commit d14d8f3

Browse files
committed
Bump 0.3.6
1 parent 51fe1a7 commit d14d8f3

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 2024-10-28 Version 0.3.6
2+
* Support IMDS v2 default for ecs ram role.
3+
14
### 2024-07-31 Version 0.3.5
25
* Support region or endpoint for sts requests.
36
* Support user agent for credentials requests.

README-CN.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ cred_type = cred.get_type()
123123

124124
#### ECS RAM Role
125125

126-
通过指定角色名称,让凭证自动申请维护 STS Token
126+
ECS和ECI实例均支持绑定实例RAM角色,当在实例中使用Credentials工具时,将自动获取实例绑定的RAM角色,并通过访问元数据服务获取RAM角色的STS Token,以完成凭据客户端的初始化。
127+
128+
实例元数据服务器支持加固模式和普通模式两种访问方式,Credentials工具默认使用加固模式(IMDSv2)获取访问凭据。若使用加固模式时发生异常,您可以通过设置disable_imds_v1来执行不同的异常处理逻辑:
129+
130+
- 当值为false(默认值)时,会使用普通模式继续获取访问凭据。
131+
132+
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
133+
134+
服务端是否支持IMDSv2,取决于您在服务器的配置。
127135

128136
```python
129137
from alibabacloud_credentials.client import Client
@@ -132,7 +140,7 @@ from alibabacloud_credentials.models import Config
132140
config = Config(
133141
type='ecs_ram_role', # 凭证类型
134142
role_name='roleName', # 账户RoleName,非必填,不填则自动获取,建议设置,可以减少请求
135-
enable_imds_v2=True # 开启 V2 安全访问,非必填,可以设置环境变量来开启:ALIBABA_CLOUD_ECS_IMDSV2_ENABLE=true
143+
disable_imds_v1=True # 选填,是否强制关闭IMDSv1,即必须使用IMDSv2加固模式,可以通过环境变量ALIBABA_CLOUD_IMDSV1_DISABLED设置
136144
)
137145
cred = Client(config)
138146

@@ -252,7 +260,13 @@ response = client.get_async_job_result(request, runtime_options)
252260

253261
3. 实例 RAM 角色
254262

255-
如果定义了环境变量 `ALIBABA_CLOUD_ECS_METADATA` 且不为空,程序会将该环境变量的值作为角色名称,请求 <http://100.100.100.200/latest/meta-data/ram/security-credentials/> 获取临时安全凭证。
263+
若不存在优先级更高的凭据信息,Credentials工具将通过环境变量获取ALIBABA_CLOUD_ECS_METADATA(ECS实例RAM角色名称)的值。若该变量的值存在,程序将采用加固模式(IMDSv2)访问ECS的元数据服务(Meta Data Server),以获取ECS实例RAM角色的STS Token作为默认凭据信息。在使用加固模式时若发生异常,将使用普通模式兜底来获取访问凭据。您也可以通过设置环境变量ALIBABA_CLOUD_IMDSV1_DISABLED,执行不同的异常处理逻辑:
264+
265+
- 当值为false时,会使用普通模式继续获取访问凭据。
266+
267+
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
268+
269+
服务端是否支持IMDSv2,取决于您在服务器的配置。
256270

257271
4. Credentials URI
258272

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ cred_type = cred.get_type()
123123

124124
#### ECS RAM Role
125125

126-
By specifying the role name, the credential will be able to automatically request maintenance of STS Token.
126+
Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client.
127+
128+
The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disable_imds_v1 to perform different exception handling logic:
129+
130+
- When the value is false (default value), the normal mode will continue to be used to obtain access credentials.
131+
132+
- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown.
133+
134+
Whether the server supports IMDSv2 depends on your configuration on the server.
127135

128136
```python
129137
from alibabacloud_credentials.client import Client
@@ -132,7 +140,7 @@ from alibabacloud_credentials.models import Config
132140
config = Config(
133141
type='ecs_ram_role', # credential type
134142
role_name='roleName', # `role_name` is optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests.
135-
enable_imds_v2=True # `enable_imds_v2` is optional and is recommended to be turned on. It can be replaced by setting environment variable: ALIBABA_CLOUD_ECS_IMDSV2_ENABLE
143+
disable_imds_v1=True # Optional, whether to forcibly disable IMDSv1, that is, to use IMDSv2 hardening mode, which can be set by the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED
136144
)
137145
cred = Client(config)
138146

@@ -250,7 +258,13 @@ The default credential provider chain looks for available credentials, with foll
250258

251259
3. Instance RAM Role
252260

253-
If the environment variable `ALIBABA_CLOUD_ECS_METADATA` is defined and not empty, the program will take the value of the environment variable as the role name and request <http://100.100.100.200/latest/meta-data/ram/security-credentials/> to get the temporary Security credentials.
261+
If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic:
262+
263+
- When the value is false, the normal mode will continue to obtain access credentials.
264+
265+
- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown.
266+
267+
Whether the server supports IMDSv2 depends on your configuration on the server.
254268

255269
4. Credentials URI
256270

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.5"
1+
__version__ = "0.3.6"

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@
5454
'Intended Audience :: Developers',
5555
'License :: OSI Approved :: Apache Software License',
5656
'Programming Language :: Python :: 3',
57-
'Programming Language :: Python :: 3.6',
5857
'Programming Language :: Python :: 3.7',
5958
'Programming Language :: Python :: 3.8',
6059
'Programming Language :: Python :: 3.9',
60+
'Programming Language :: Python :: 3.10',
61+
'Programming Language :: Python :: 3.11',
62+
'Programming Language :: Python :: 3.12',
6163
'Topic :: Software Development',
6264
)
6365
}

0 commit comments

Comments
 (0)