If you want to access Intelligent Media Services (IMS) on mobile or web clients, you can use Security Token Service (STS) to authorize temporary access. This effectively prevents security risks caused by leaks of the AccessKey pairs of Resource Access Management (RAM) users. This topic describes how to use STS to authorize temporary access to IMS.
Background information
AccessKey pairs of RAM users are permanently valid after the AccessKey pairs are enabled. If the AccessKey pairs are leaked, security risks may occur. We recommend that you use STS to authorize temporary access. You can customize the validity period of temporary AccessKey pairs, specify relatively complex policies to limit the permissions of different RAM roles, and abide by the principle of least privilege to improve service access security.
Step 1: Create a RAM user and authorize the RAM user to call the AssumeRole operation
Log on to the RAM console by using an Alibaba Cloud account or a RAM user who has administrative rights.
In the left-side navigation pane, choose .
On the Users page, click Create User.
In the User Account Information section of the Create User page, configure the following parameters:
Logon Name: The logon name can be up to 64 characters in length, and can contain letters, digits, periods (.), hyphens (-), and underscores (_).
Display Name: The display name can be up to 128 characters in length.
Tag: Click the icon and enter a tag key and a tag value. You can add one or more tags to the RAM user. This way, you can manage the RAM user based on the tags.
NoteYou can click Add User to create multiple RAM users at a time.
Select OpenAPI Access for the Access Mode parameter.
Click OK and complete the security verification. An AccessKey pair is automatically generated for the RAM user.
Click Copy in the Actions column and save the copied user information including the AccessKey ID and AccessKey secret.
ImportantKeep the AccessKey pair secure. The AccessKey secret is displayed only when the RAM user is created. You cannot view the AccessKey secret after you close the creation page.
On the Users page, find the created RAM user and click Add Permissions in the Actions column.
In the Grant Permission panel, grant permissions to the RAM user.
Specify the authorization scope.
Set the Resource Scope parameter to Account. IMS does not allow you to set the Resource Scope parameter to ResourceGroup. For more information about resource groups, see Differences and relationships among the Resource Directory, Resource Group, and Tag services.
Specify the principal.
The principal is the RAM user to which you want to grant permissions.
Select a policy in the Policy section.
Select System Policy from the drop-down list, enter AliyunSTS in the search box, and then select the AliyunSTSAssumeRoleAccess policy.
Click Grant permissions.
Step 2: Create a RAM role and authorize the RAM role to operate IMS resources
Log on to the RAM console as a RAM user who has administrative rights.
In the left-side navigation pane, choose .
On the Roles page, click Create Role.
On the Create Role page, select Alibaba Cloud Account in the Select Role Type section and click Next.
Configure parameters for the RAM role.
Specify RAM Role Name.
Specify Note.
Select Current Alibaba Cloud Account or Other Alibaba Cloud Account in the Select Trusted Alibaba Cloud Account section.
Current Alibaba Cloud Account: If you want a RAM user that belongs to your Alibaba Cloud account to assume the RAM role, select Current Alibaba Cloud Account.
Other Alibaba Cloud Account: If you want a RAM user that belongs to a different Alibaba Cloud account to assume the RAM role, select Other Alibaba Cloud Account and enter the ID of the Alibaba Cloud account. This option is provided to grant permissions on resources that belong to different Alibaba Cloud accounts. For more information, see Use a RAM role to grant permissions across Alibaba Cloud accounts.
You can view the ID of your Alibaba Cloud account on the Security Settings page.
ImportantIf you want a specific RAM user instead of all RAM users that belong to your Alibaba Cloud account to assume the RAM role, you can use one of the following methods:
Modify the trust policy of the RAM role. For more information, see Example 1: Change the trusted entity of a RAM role to an Alibaba Cloud account.
Modify the role-assuming policy that is attached to the RAM user. For more information, see Can I specify the RAM role that a RAM user can assume?
Click OK.
Click Add Permissions to RAM role.
In the Grant Permission panel, grant permissions to the RAM role.
Specify the authorization scope.
Set the Resource Scope parameter to Account. IMS does not allow you to set the Resource Scope parameter to ResourceGroup. For more information about resource groups, see Differences and relationships among the Resource Directory, Resource Group, and Tag services.
Specify the principal.
The principal is the RAM role to which permissions are granted. By default, the current RAM role is specified. You can also specify a different RAM role.
Select policies in the Policy section.
Use system policies
Select System Policy from the drop-down list, enter AliyunICE in the search box, and then select system policies based on your business requirements.
Policy Description API operation AliyunICEFullAccess Permissions to manage and operate all IMS resources This policy grants permissions on all operations of IMS. AliyunICEReadOnlyAccess Read-only permissions on all IMS resources This policy grants permissions on all read-only operations of IMS, such as Get, Describe, Search, and List operations. Use custom policies
Select Custom Policy from the drop-down list and select custom policies based on your business requirements. If no custom policies are available, click Create Policy. For more information, see Create custom policies or the Sample custom policies section of this topic.
NoteYou can attach a maximum of five policies to a RAM user at a time. If you want to attach more than five policies to a RAM user, repeat the operation.
To control risks, we recommend that you abide by the principle of least privilege.
If you want to use IMS SDK for iOS or Android, you must specify the
AliyunOSSFullAccess
policy or a custom Object Storage Service (OSS) policy based on your business requirements. This is because the SDK needs to upload files to OSS.
Click Grant permissions.
Step 3: Use the created RAM user to call the AssumeRole operation to obtain a temporary AccessKey pair
Download and integrate STS SDK. For more information about how to download STS SDK, see STS SDK overview.
Call the AssumeRole operation to assume the created RAM role and obtain an STS temporary AccessKey pair.
In this example, sample code in Java is provided. For more information about sample code in other programming languages, see STS SDK overview.