All Products
Search
Document Center

Resource Access Management:SetSecurityPreference

Last Updated:Mar 03, 2024

Configures security preferences for a RAM user.

Operation 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.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ram:SetSecurityPreferenceWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
EnableSaveMFATicketbooleanNo

Specifies whether RAM users can remember the MFA devices for seven days. Valid values:

  • true
  • false (default)
false
AllowUserToChangePasswordbooleanNo

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

  • true (default)
  • false
true
AllowUserToManageAccessKeysbooleanNo

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

  • true
  • false (default)
false
AllowUserToManageMFADevicesbooleanNo

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

  • true (default)
  • false
true
LoginSessionDurationintegerNo

The validity period of the logon session of RAM users.

Valid values: 1 to 24. Unit: hours.

Default value: 6.

6
LoginNetworkMasksstringNo

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). 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 40 subnet masks. The total length of the subnet masks can be a maximum of 512 characters.

10.0.0.0/8
VerificationTypesarrayNo

The MFA methods.

stringNo

The MFA method. Valid values:

  • sms: mobile phone
  • email: email
["sms", "email"]
AllowUserToManagePersonalDingTalkbooleanNo

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

  • true (default)
  • false
true
OperationForRiskLoginstringNo

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

  • autonomous (default): yes. MFA is prompted for RAM users who initiated unusual logons. However, the RAM users are allowed to skip MFA.
  • enforceVerify: MFA is prompted for RAM users who initiated unusual logons and the RAM users cannot skip MFA.
autonomous
MFAOperationForLoginstringNo

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 EnforceMFAForLogin. EnforceMFAForLogin is still valid. However, we recommend that you use MFAOperationForLogin. Valid values:

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

For more information about common request parameters, see API Reference.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

SecurityPreferenceobject

The details of security preferences.

AccessKeyPreferenceobject

The AccessKey pair preference.

AllowUserToManageAccessKeysboolean

Indicates whether RAM users can manage their AccessKey pairs.

false
LoginProfilePreferenceobject

The logon preference.

EnableSaveMFATicketboolean

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

false
LoginSessionDurationinteger

The validity period of the logon session of RAM users.

6
LoginNetworkMasksstring

The subnet mask.

10.0.0.0/8
AllowUserToChangePasswordboolean

Indicates whether RAM users can change their passwords.

true
OperationForRiskLoginstring

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

autonomous
MFAOperationForLoginstring

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

adaptive
MFAPreferenceobject

The MFA preference.

AllowUserToManageMFADevicesboolean

Indicates whether RAM users can manage their MFA devices.

false
VerificationPreferenceobject

The MFA method preference.

VerificationTypesarray

The MFA methods.

string

The MFA method.

["sms", "email"]
PersonalInfoPreferenceobject

The personal information preference.

AllowUserToManagePersonalDingTalkboolean

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

true
RequestIdstring

The request ID.

17494710-B4BA-4185-BBBB-C1A6ABDE1639

Examples

Sample success responses

JSONformat

{
  "SecurityPreference": {
    "AccessKeyPreference": {
      "AllowUserToManageAccessKeys": false
    },
    "LoginProfilePreference": {
      "EnableSaveMFATicket": false,
      "LoginSessionDuration": 6,
      "LoginNetworkMasks": "10.0.0.0/8",
      "AllowUserToChangePassword": true,
      "OperationForRiskLogin": "autonomous",
      "MFAOperationForLogin": "adaptive"
    },
    "MFAPreference": {
      "AllowUserToManageMFADevices": false
    },
    "VerificationPreference": {
      "VerificationTypes": [
        "[\"sms\", \"email\"]"
      ]
    },
    "PersonalInfoPreference": {
      "AllowUserToManagePersonalDingTalk": true
    }
  },
  "RequestId": "17494710-B4BA-4185-BBBB-C1A6ABDE1639"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-03-20The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: VerificationTypes
Output ParametersThe response structure of the API has changed.
2023-01-06The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: OperationForRiskLogin
    Added Input Parameters: MFAOperationForLogin
    delete Input Parameters: EnforceMFAForLogin
Output ParametersThe response structure of the API has changed.
2021-08-11The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: VerificationTypes
Output ParametersThe response structure of the API has changed.
2021-08-11The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: EnforceMFAForLogin
Output ParametersThe response structure of the API has changed.