Updated on 2026-09-23 GMT+08:00

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

To set source identity information, your policy must contain the following action in addition to the sts:agencies:assume permission that matches the AssumeAgency API:
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.
As an account administrator, you may want to allow IAM user A to assume TrustAgencyA in the same account only if the source identity is the IAM username. You can attach the following identity policy to the IAM user:
{
	"Version": "5.0",
	"Statement": [{
		"Effect": "Allow",
		"Action": [
			"sts:agencies:assume",
			"sts::setSourceIdentity"
		],
		"Condition": {
			"StringEquals": {
				"sts:SourceIdentity": [
					"${g:UserName}"
				]
			}
		}
	}]
}
To require that the source principal information must be passed during trust agency assuming, add a trust policy when creating trust agency A. For example, you can configure a trust policy to allow trust agency assuming only when IAM user A passes its username as the source principal information.
{
	"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

The AssumeAgencyWithSAML API authenticates identities using SAML identity providers and returns temporary security credentials to access Huawei Cloud resources. As an administrator, you can enable members of your organization to federate into Huawei Cloud by using this API. To do so, complete the following tasks:
  • 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.

For example, to pass ZhangSan as the source identity, configure the SAML assertion with the following XML fragment:
<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.

For example, the following decoded OIDC token is a token used to call the AssumeAgencyWithOIDC API with "Admin" as the source identity.
{
    "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.

Assume you want to require developers to set a source identity when they switch to a trust agency that has write permissions to production-critical resources. Also, assume you use the AssumeAgencyWithSAML API to grant your employees access to Huawei Cloud. You want only senior developers ZhangSan and LiSi to be able to switch to this trust agency. To enforce this, you create the following trust policy for the trust agency. This policy contains an sts:SourceIdentity condition requiring that the trust agency can only be switched to when the source identity is set to ZhangSan or LiSi.
{
    "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"
                    ]
                }
            }
        }
    ]
}
Alternatively, if you use an OIDC IdP for identity federation and users authenticate via the AssumeAgencyWithOIDC API, the trust policy for your trust agency would look like this:
{
    "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

If IAM user A uses the new assumed-trust agency session to perform operations on Huawei Cloud, you will find the source_identity information in the user field of CTS logs recording these operations.
{
	"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
}