Configures the security preferences for Resource Access Management (RAM) users.

Description

This topic provides an example on how to enable multi-factor authentication (MFA) only for RAM users who initiated unusual logons.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameter

Parameter Type Required Example Description
Action String Yes SetSecurityPreference

The operation that you want to perform. Set the value to SetSecurityPreference.

EnableSaveMFATicket Boolean No false

Specifies whether to remember the MFA devices for seven days. Valid values:

  • true: yes.
  • false: no. This is the default value.
AllowUserToChangePassword Boolean No true

Specifies whether RAM users can change their passwords. Valid values:

  • true: yes. This is the default value.
  • false: no.
AllowUserToManageAccessKeys Boolean No false

Specifies whether RAM users can manage their AccessKey pairs. Valid values:

  • true: yes.
  • false: no. This is the default value.
AllowUserToManageMFADevices Boolean No true

Specifies whether RAM users can manage their MFA devices. Valid values:

  • true: yes. This is the default value.
  • false: no.
LoginSessionDuration Integer No 6

The validity period of the logon session of RAM users.

Valid values: 1 to 24. Unit: hours.

Default value: 6.

LoginNetworkMasks String No 10.0.0.0/8

The subnet mask that specifies the IP addresses from which you can log on to the Alibaba Cloud Management Console. This parameter takes effect on password-based logon and single sign-on (SSO). However, this parameter does not take effect on API calls that are authenticated by using AccessKey pairs.

  • If you specify a subnet mask, RAM users can use only the IP addresses in the subnet mask to log on to the Alibaba Cloud Management Console.
  • If you do not specify a subnet mask, RAM users can use all IP addresses to log on to the Alibaba Cloud Management Console.

If you need to specify multiple subnet masks, separate the subnet masks with semicolons (;). Example: 192.168.0.0/16;10.0.0.0/8.

You can specify up to 25 subnet masks. The total length of the subnet masks can be a maximum of 512 characters.

AllowUserToManagePersonalDingTalk Boolean No true

Specifies whether RAM users can manage their personal DingTalk accounts, such as binding and unbinding of the accounts. Valid values:

  • true: yes. This is the default value.
  • false: no.
OperationForRiskLogin String No autonomous

Specifies whether to enable MFA for RAM users who initiated unusual logons. Valid values:

  • autonomous: yes. MFA is prompted for RAM users who initiated unusual logons. However, the RAM users are allowed to skip MFA. This is the default value.
  • enforceVerify: no.
MFAOperationForLogin String No adaptive

Specifies whether MFA is required for all RAM users when they log on to the Alibaba Cloud Management Console. This parameter is used to replace the EnforceMFAForLogin parameter. The EnforceMFAForLogin parameter is still valid. However, we recommend that you use the MFAOperationForLogin parameter. Valid values:

  • mandatory: MFA is required for all RAM users. If you use the EnforceMFAForLogin parameter, set the value to true.
  • independent: User-specific settings are applied. This is the default value. If you use the EnforceMFAForLogin parameter, set the value to false.
  • adaptive: MFA is required only for RAM users who initiated unusual logons.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
SecurityPreference Object

The details of security preferences.

AccessKeyPreference Object

The AccessKey pair preference.

AllowUserToManageAccessKeys Boolean false

Indicates whether RAM users can manage their AccessKey pairs.

LoginProfilePreference Object

The logon preference.

EnableSaveMFATicket Boolean false

Indicates whether RAM users can remember the MFA devices for seven days.

LoginSessionDuration Integer 6

The validity period of the logon session of RAM users.

LoginNetworkMasks String 10.0.0.0/8

The subnet mask.

AllowUserToChangePassword Boolean true

Indicates whether RAM users can change their passwords.

OperationForRiskLogin String autonomous

Indicates whether to enable MFA for RAM users who initiated unusual logons.

MFAOperationForLogin String adaptive

Indicates whether MFA is required for all RAM users when they log on to the Alibaba Cloud Management Console.

MFAPreference Object

The MFA preference.

AllowUserToManageMFADevices Boolean false

Indicates whether RAM users can manage their MFA devices.

PersonalInfoPreference Object

The personal information preference.

AllowUserToManagePersonalDingTalk Boolean true

Indicates whether RAM users can manage their personal DingTalk accounts, such as binding and unbinding of the accounts.

RequestId String 17494710-B4BA-4185-BBBB-C1A6ABDE1639

The ID of the request.

Examples

Sample requests

https://[Endpoint]/?Action=SetSecurityPreference
&MFAOperationForLogin=adaptive
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<SetSecurityPreferenceResponse>
    <SecurityPreference>
        <AccessKeyPreference>
            <AllowUserToManageAccessKeys>false</AllowUserToManageAccessKeys>
        </AccessKeyPreference>
        <LoginProfilePreference>
            <EnableSaveMFATicket>false</EnableSaveMFATicket>
            <LoginSessionDuration>6</LoginSessionDuration>
            <LoginNetworkMasks/>
            <AllowUserToChangePassword>true</AllowUserToChangePassword>
            <OperationForRiskLogin>autonomous</OperationForRiskLogin>
            <MFAOperationForLogin>adaptive</MFAOperationForLogin>
        </LoginProfilePreference>
        <MFAPreference>
            <AllowUserToManageMFADevices>false</AllowUserToManageMFADevices>
        </MFAPreference>
        <PersonalInfoPreference>
            <AllowUserToManagePersonalDingTalk>true</AllowUserToManagePersonalDingTalk>
        </PersonalInfoPreference>
    </SecurityPreference>
    <RequestId>17494710-B4BA-4185-BBBB-C1A6ABDE1639</RequestId>
</SetSecurityPreferenceResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "SecurityPreference" : {
    "AccessKeyPreference" : {
      "AllowUserToManageAccessKeys" : false
    },
    "LoginProfilePreference" : {
      "EnableSaveMFATicket" : false,
      "LoginSessionDuration" : 6,
      "LoginNetworkMasks" : "",
      "AllowUserToChangePassword" : true,
      "OperationForRiskLogin" : "autonomous",
      "MFAOperationForLogin" : "adaptive"
    },
    "MFAPreference" : {
      "AllowUserToManageMFADevices" : false
    },
    "PersonalInfoPreference" : {
      "AllowUserToManagePersonalDingTalk" : true
    }
  },
  "RequestId" : "17494710-B4BA-4185-BBBB-C1A6ABDE1639"
}

Error codes

For a list of error codes, see Service error codes.