For role-based single sign-on (SSO) that uses Security Assertion Markup Language (SAML), call the AssumeRoleWithSAML operation to obtain a temporary identity credential (a Security Token Service (STS) token) for a RAM role.
Operation description
Prerequisites
Obtain a SAML response from an external identity provider (IdP).
Create a SAML identity provider in Resource Access Management (RAM). For more information, see Create a SAML identity provider or CreateSAMLProvider.
Create a RAM role for a SAML identity provider. For more information, see Create a RAM role for an identity provider or CreateRole.
Try it now
Test RAM authorization
Request parameters
| Parameter | Type | Required | Description | Example |
| SAMLProviderArn | string | No | The Alibaba Cloud Resource Name (ARN) of the SAML IdP that is created in RAM. Format: You can view the ARN of the IdP in the RAM console or by calling an API operation:
| acs:ram::123456789012****:saml-provider/company1 |
| RoleArn | string | No | The ARN of the RAM role to assume. The trusted entity of the RAM role is a SAML IdP. For more information, see Create a RAM role for an identity provider or CreateRole. Format: You can view the ARN of the role in the RAM console or by calling an API operation:
| acs:ram::123456789012****:role/adminrole |
| SAMLAssertion | string | No | The Base64-encoded SAML assertion. The value must be 4 to 100,000 characters in length. Note Obtain the complete SAML response from the IdP. Do not use only the SAML assertion field. | base64_encoded_saml_assertion |
| Policy | string | No | An access policy to further limit the permissions of the STS token. This parameter works as follows:
The value must be 1 to 2,048 characters in length. | url_encoded_policy |
| DurationSeconds | integer | No | The expiration duration of the token. Unit: seconds. The minimum value is 900 seconds. The maximum value is the value of the You can set the | 3600 |
Because the AssumeRoleWithSAML operation uses a SAML assertion for identity authentication and allows anonymous access, you do not need to specify the common request parameters Signature, SignatureMethod, SignatureVersion, or AccessKeyId. For more information about common request parameters, see Common request parameters.
Response parameters
| Parameter | Type | Description | Example |
| object | The response parameters. | ||
| RequestId | string | The request ID. | 6894B13B-6D71-4EF5-88FA-F32781734A7F |
| SAMLAssertionInfo | object | The information about the SAML assertion. | |
| SubjectType | string | The format of the NameID element in the SAML assertion. If the prefix is | persistent |
| Subject | string | The value of the | alice@example.com |
| Issuer | string | The value of the | http://example.com/adfs/services/trust |
| Recipient | string | The value of the | https://signin.aliyun.com/saml-role/SSO |
| AssumedRoleUser | object | The temporary identity of the assumed role. | |
| AssumedRoleId | string | The ID of the temporary identity. | 34458433936495****:alice |
| Arn | string | The ARN of the temporary identity. | acs:sts::123456789012****:assumed-role/AdminRole/alice |
| Credentials | object | The access credential. | |
| SecurityToken | string | The security token. Note The security token has a variable length. Do not impose a maximum length limit on the security token. | ******** |
| Expiration | string | The expiration time of the token. The time is in UTC. | 2015-04-09T11:52:19Z |
| AccessKeySecret | string | The AccessKey secret. | wyLTSmsyPGP1ohvvw8xYgB29dlGI8KMiH2pK**** |
| AccessKeyId | string | The AccessKey ID. | STS.L4aBSCSJVMuKg5U1**** |
| SourceIdentity | string | The source identity. When you assume a role, you can specify a source identity for the role user. The source identity is used as the initial identity of the session. The value of the source identity persists throughout chained role-assuming sessions and cannot be changed. This ensures the traceability and security of operations. This parameter is not returned if you do not set a source identity. | Alice |
Examples
Success response
JSON format
{ "RequestId": "6894B13B-6D71-4EF5-88FA-F32781734A7F", "SAMLAssertionInfo": { "SubjectType": "persistent", "Subject": "alice@example.com", "Issuer": "http://example.com/adfs/services/trust", "Recipient": "https://signin.aliyun.com/saml-role/SSO" }, "AssumedRoleUser": { "AssumedRoleId": "34458433936495****:alice", "Arn": "acs:sts::123456789012****:assumed-role/AdminRole/alice" }, "Credentials": { "SecurityToken": "********", "Expiration": "2015-04-09T11:52:19Z", "AccessKeySecret": "wyLTSmsyPGP1ohvvw8xYgB29dlGI8KMiH2pK****", "AccessKeyId": "STS.L4aBSCSJVMuKg5U1****" }, "SourceIdentity": "Alice" } Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 500 | InternalError | STS Server Internal Error happened, please send the RequestId to us. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.