Applying an MFA policy to users
For an MFA policy to apply to user accounts, you need to explicitly add the relevant users or the groups they are members of to the policy's target groups.
-
Log in to Yandex Identity Hub
. -
In the left-hand panel, select
Security settings. -
Navigate to the MFA policies tab and select the policy you need from the list. In the window that opens:
-
Navigate to the Users and groups tab.
-
To add a new user or group to the policy's target groups:
- Click
Add users. - In the window that opens, select the required user or user group.
- Click Add.
- Click
-
To delete a user or group from the policy:
- In the list of users and groups, click
and select Delete next to the user or user group. - Confirm the deletion.
- In the list of users and groups, click
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id options.
-
View a list of users or groups subject to the MFA policy:
yc organization-manager mfa-enforcement list-audience \ --id <policy_ID> -
See the description of the CLI command for changing the list of users or groups subject to the MFA policy:
yc organization-manager mfa-enforcement update-audience --help -
To add users or groups to the MFA policy, or to remove them from it, run this command:
yc organization-manager mfa-enforcement update-audience \ --id <policy_ID> \ --audience-delta subject-id=<subject_ID>,action=<action>Where:
--audience-delta: Parameter to edit the list of users/groups in the policy:subject-id: User or group ID.action: Action,action-addto add,action-removeto delete.
You can specify multiple
--audience-deltaparameters to edit more than one object at the same time.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
To add a user or group to an MFA policy, describe the
yandex_organizationmanager_mfa_enforcement_audienceresource parameters in the configuration file:resource "yandex_organizationmanager_mfa_enforcement_audience" "example_mfa_audience" { mfa_enforcement_id = "<MFA_policy_ID>" subject_id = "<user_or_group_ID>" }Where:
mfa_enforcement_id: ID of the MFA policy to which you want to add a user or group. This is a required parameter.subject-id: ID of the user or group you need to add to the MFA policy. This is a required parameter.
To add multiple users or groups, create a separate
yandex_organizationmanager_mfa_enforcement_audienceresource for each one.For more information about
yandex_organizationmanager_mfa_enforcement_audienceproperties, see this provider guide. -
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can make sure the users were added to the MFA policy using the Cloud Center UI
or this CLI command:yc organization-manager mfa-enforcement list-audience --id <policy_ID> -
-
To delete a user or group from an MFA policy, delete the relevant
yandex_organizationmanager_mfa_enforcement_audienceresource from the configuration file and apply the changes.
Use the UpdateAudience REST API method for the MfaEnforcement resource or the MfaEnforcementService/UpdateAudience gRPC API call.
Note
You can add any type of user accounts to the MFA policy target groups, but the policy will only apply to federated and local user accounts.
If a group added to an MFA policy includes users with different account types, the policy will only apply to users with federated and local accounts.