修改账号密码策略
调试
您可以在API Explorer中调试该接口。
URI
PUT /v3.0/OS-SECURITYPOLICY/domains/{domain_id}/password-policy
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| domain_id | 是 | String | 账号ID,获取方式请参见:获取账号、IAM用户、项目、用户组、区域、委托的名称和ID。 | 
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| X-Auth-Token | 是 | String | 访问令牌,承载用户的身份、权限等信息。 token所需权限请参见授权项。 | 
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| 是 | object | 密码策略。 | 
| 参数 | 是否必选 | 参数类型 | 描述 | 
|---|---|---|---|
| maximum_consecutive_identical_chars | 否 | Integer | 同一字符连续出现的最大次数,取值范围[0,32]。 | 
| minimum_password_age | 否 | Integer | 密码最短使用时间(分钟),取值范围[0,1440]。 | 
| minimum_password_length | 否 | Integer | 密码最小字符数,取值范围[8,32]。 | 
| number_of_recent_passwords_disallowed | 否 | Integer | 密码不能与历史密码重复次数,取值范围[0,24]。 | 
| password_not_username_or_invert | 否 | Boolean | 密码是否可以是用户名或用户名的反序。 | 
| password_validity_period | 否 | Integer | 密码有效期(天),取值范围[0,180],设置0表示关闭该策略。 | 
| password_char_combination | 否 | Integer | 至少包含字符种类的个数,取值区间[2,4]。 | 
响应参数
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| object | 密码策略。 | 
| 参数 | 参数类型 | 描述 | 
|---|---|---|
| maximum_consecutive_identical_chars | Integer | 同一字符连续出现的最大次数。 | 
| maximum_password_length | Integer | 密码最大字符数。 | 
| minimum_password_age | Integer | 密码最短使用时间(分钟)。 | 
| minimum_password_length | Integer | 密码最小字符数。 | 
| number_of_recent_passwords_disallowed | Integer | 密码不能与历史密码重复次数。 | 
| password_not_username_or_invert | Boolean | 密码是否可以是用户名或用户名的反序。 | 
| password_requirements | String | 设置密码必须包含的字符要求。 | 
| password_validity_period | Integer | 密码有效期(天)。 | 
| password_char_combination | Integer | 至少包含字符种类的个数,取值区间[2,4]。 | 
请求示例
修改账号的密码策略:密码最少为8个字符,密码不能与近2次历史密码重复,密码最短使用时间为20分钟,密码有效期为60天,同一字符连续出现的最大次数为3,密码不可以是用户名或用户名的反序,至少包含3种字符类型。
PUT https://iam.myhuaweicloud.com/v3.0/OS-SECURITYPOLICY/domains/{domain_id}/password-policy 
 
{ 
  "password_policy" : { 
    "minimum_password_length" : 8, 
    "number_of_recent_passwords_disallowed" : 2, 
    "minimum_password_age" : 20, 
    "password_validity_period" : 60, 
    "maximum_consecutive_identical_chars" : 3, 
    "password_not_username_or_invert" : false,
    "password_char_combination" : 3
  } 
}
 响应示例
状态码为 200 时:
请求成功。
{ 
  "password_policy" : { 
    "password_requirements" : "A password must contain at least two of the following: uppercase letters, lowercase letters, digits, and special characters.", 
    "minimum_password_age" : 20, 
    "minimum_password_length" : 8, 
    "maximum_password_length" : 32, 
    "number_of_recent_passwords_disallowed" : 2, 
    "password_validity_period" : 60, 
    "maximum_consecutive_identical_chars" : 3, 
    "password_not_username_or_invert" : true,
    "password_char_combination" : 3
  } 
}
 状态码为 400 时:
请求体异常。
- 示例 1
{ 
   "error_msg" : "'%(key)s' is a required property.", 
   "error_code" : "IAM.0072" 
 }
 - 示例 2
{ 
   "error_msg" : "Invalid input for field '%(key)s'. The value is '%(value)s'.", 
   "error_code" : "IAM.0073" 
 }
 状态码为 403 时:
鉴权失败。
- 示例 1
{ 
   "error_msg" : "You are not authorized to perform the requested action.", 
   "error_code" : "IAM.0002" 
 }
 - 示例 2
{ 
   "error_msg" : "Policy doesn't allow %(actions)s to be performed.", 
   "error_code" : "IAM.0003" 
 }
 状态码为 500 时:
系统异常。
{ 
  "error_msg" : "An unexpected error prevented the server from fulfilling your request.", 
  "error_code" : "IAM.0006" 
}
 状态码
| 状态码 | 描述 | 
|---|---|
| 200 | 请求成功。 | 
| 400 | 请求体异常。 | 
| 401 | 认证失败。 | 
| 403 | 鉴权失败。 | 
| 500 | 系统异常。 | 
错误码
请参见错误码。
 
    