Monitoring Temporary Security Credentials
When performing operations on Huawei Cloud, you can record call logs in CTS for account administrators to monitor. When configuring a trust agency, administrators can require that a custom string be passed to identify the user or application performing the operations on Huawei Cloud. This string is stored as the source identity information in CTS. When viewing activities in CTS, the administrator can determine who assumed the trust agency to perform operations based on the source identity information. Similarly, when the AssumeAgencyWithSAML or AssumeAgencyWithOIDC API is called, source identity information can be passed in the SAML assertion or ID token. These capabilities are equivalent to those of the AssumeAgency API.
After the source identity information is set, it is included in any Huawei Cloud operation request processed during the assumed-trust agency session. If you use the AssumeAgency API to assume another trust agency in an agency chain, the source identity information will be passed from one to another and cannot be changed. Administrators can configure identity policies based on whether there is source identity information and its value to control Huawei Cloud operations allowed for trust agencies. You can determine whether to use the source identity information and what it can be.
Permissions Required for Setting Source Identity Information
sts::setSourceIdentity
- To specify source identity information for an IAM user to assume a trust agency, the identity policy of the IAM user and the trust policy of the trust agency must have the sts::setSourceIdentity permission.
- To specify source identity information for an agency to assume another agency, the identity policy of the agency initiating the assumption and the trust policy of the target agency must have the sts::setSourceIdentity permission.
{
"Version": "5.0",
"Statement": [{
"Effect": "Allow",
"Action": [
"sts:agencies:assume",
"sts::setSourceIdentity"
],
"Condition": {
"StringEquals": {
"sts:SourceIdentity": [
"${g:UserName}"
]
}
}
}]
} {
"Version": "5.0",
"Statement": [{
"Effect": "Allow",
"Action": [
"sts:agencies:assume",
"sts::setSourceIdentity"
],
"Condition": {
"StringEquals": {
"sts:SourceIdentity": [
"${g:UserName}"
]
}
}
}]
} Using the Source Identity in the AssumeAgency API
When using the AssumeAgency API to obtain temporary security credentials for accessing Huawei Cloud resources, you can include source identity information. To pass the source identity when calling this API, you must configure the necessary permissions in the identity policy and trust policy, and specify the source_identity parameter. This embeds the source identity into the temporary security credentials, allowing it to be propagated throughout subsequent agency chains.
Using the Source Identity in the AssumeAgencyWithSAML API
- Configure a SAML identity provider within your company or organization.
- Create a SAML identity provider in IAM.
- Configure a trust agency and its permissions for your SAML identity provider in IAM.
- Finalize the SAML identity provider configuration and generate a SAML assertion for the SAML authentication response.
To set a SAML attribute for the source identity, include an Attribute element with the Name attribute set to https://www.huaweicloud.com/SAML/Attributes/SourceIdentity. Use the AttributeValue element to define the source identity, which serves as an identifier for the person or application using the trust agency. The source identity value persists when you utilize a SAML session to assume a subsequent trust agency, a process referred to as agency chaining. This value remains constant for the duration of the session and is included in all action requests performed.
<Attribute Name="https://www.huaweicloud.com/SAML/Attributes/SourceIdentity"> <AttributeValue>ZhangSan</AttributeValue> </Attribute>
Using Source Identity in the AssumeAgencyWithOIDC API
The AssumeAgencyWithOIDC API authenticates users based on an OIDC IdP and returns a set of temporary security credentials that can be used to access Huawei Cloud resources. To pass a source identity in the AssumeAgencyWithOIDC API, you must include the source identity field in the OIDC token. When submitting an AssumeAgencyWithOIDC request, set the source identity under the https://www.huaweicloud.com/source_identity namespace within the token.
{
"sub": "repo:example-labs/oidc-with-hwc:ref:refs/heads/main",
"aud": "sts.myhuaweicloud.com",
"jti": "ZYUCeRMQVtqHypVPWAN3VB",
"iss": "https://xxx.com",
"iat": 1767196800,
"exp": 1767197100,
"auth_time": 1767196800,
"https://www.huaweicloud.com/source_identity": "Admin"
} Controlling Access Using Source Identity Information
When a source identity is initially configured, the request to switch the agency validates the sts:SourceIdentity condition key. Once configured, the g:SourceIdentity condition key can be validated in all subsequent requests made during that agency session. As an administrator, you can write policies based on the presence or the value of the source identity to grant conditional authorization for calling Huawei Cloud APIs.
{
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "iam::111122223333:samlProvider:name-of-identity-provider"
},
"Action": [
"sts:agencies:assumeWithSAML"
],
"Condition": {
"StringEquals": {
"saml:aud": "https://auth.huaweicloud.com/authui/v5/saml"
}
}
},
{
"Effect": "Allow",
"Principal": {
"Federated": "iam::111122223333:samlProvider:name-of-identity-provider"
},
"Action": [
"sts::SetSourceIdentity"
],
"Condition": {
"StringEquals": {
"sts:SourceIdentity": [
"ZhangSan",
"LiSi"
]
}
}
}
]
} {
"Version": "5.0",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "iam::111122223333:oidcProvider:name-of-identity-provider"
},
"Action": [
"sts:agencies:assumeWithOIDC",
"sts::SetSourceIdentity"
],
"Condition": {
"StringEquals": {
"oidc:aud": "android-app-id",
"oidc:iss": "https://www.sample.com",
"oidc:sub": "sub-sample",
"oidc:amr": [
"pwd",
"mfa"
],
"sts:SourceIdentity": [
"ZhangSan",
"LiSi"
]
}
}
}
]
} Viewing Source Identity Information in CTS
{
"api_version": "v5",
"code": "204",
"account_id": "xxxxxx",
"event_type": "global",
"message": "xxxxxx",
"operation_id": "DeleteUserV5",
"project_id": "xxxxxx",
"read_only": false,
"request_id": "xxxxxx",
"resource_account_id": "xxxxxx",
"resource_id": "xxxxxx",
"resource_name": "xxxxxx",
"resource_type": "user",
"service_type": "IAM",
"source_ip": "xxx.xxx.xxx.xxx",
"trace_id": "xxxxxx",
"trace_name": "deleteUserV5",
"trace_rating": "normal",
"trace_type": "ApiCall",
"tracker_name": "system",
"user_agent": "xxxxxx",
"is_consistent": true,
"user": {
"access_key_id": "xxxxxx",
"account_id": "xxxxxx",
"domain": {
"id": "xxxxxx",
"name": "xxxxxx"
},
"name": "xxxxxx/test",
"principal_id": "xxxxxx:name",
"principal_urn": "sts::xxxxxx:assumed-agency:test/name",
"session_context": {
"assumed_by": {
"principal_id": "xxxxxx"
},
"attributes": {
"created_at": "xxxxxx",
"mfa_authenticated": "false"
},
"source_identity": "IAM User A"
},
"type": "AssumedAgency"
},
"response": "null",
"time": xxxxxx,
"record_time": xxxxxx
} What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot