All Products
Search
Document Center

Resource Access Management:AssumeRoleWithSAML

Last Updated:Jun 10, 2026

Untuk single sign-on (SSO) berbasis peran yang menggunakan Security Assertion Markup Language (SAML), panggil operasi AssumeRoleWithSAML untuk mendapatkan kredensial identitas sementara (token Security Token Service (STS)) untuk peran RAM.

Deskripsi operasi

Prerequisites

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tidak ada otorisasi untuk operasi ini. Jika Anda mengalami masalah saat menjalankan operasi ini, hubungi dukungan teknis.

Parameter permintaan

Parameter

Type

Required

Description

Example

SAMLProviderArn

string

No

Nama Sumber Daya Alibaba Cloud Penyedia Identitas SAML yang dibuat di RAM.

Format: acs:ram::<account_id>:saml-provider/<saml_provider_name>.

Anda dapat melihat Nama Sumber Daya Alibaba Cloud IdP di Konsol RAM atau dengan memanggil operasi API:

acs:ram::123456789012****:saml-provider/company1

RoleArn

string

No

Nama Sumber Daya Alibaba Cloud Peran RAM yang akan diasumsikan.

Entitas tepercaya Peran RAM adalah Penyedia Identitas SAML. Untuk informasi selengkapnya, lihat Membuat peran RAM untuk penyedia identitas atau CreateRole.

Format: acs:ram::<account_id>:role/<role_name>.

Anda dapat melihat Nama Sumber Daya Alibaba Cloud peran di Konsol RAM atau dengan memanggil operasi API:

acs:ram::123456789012****:role/adminrole

SAMLAssertion

string

No

Pernyataan SAML yang dienkode Base64.

Nilai harus memiliki panjang 4 hingga 100.000 karakter.

Catatan

Ambil tanggapan SAML lengkap dari IdP. Jangan hanya menggunakan bidang pernyataan SAML.

base64_encoded_saml_assertion

Policy

string

No

Kebijakan akses untuk membatasi lebih lanjut izin token STS. Parameter ini berfungsi sebagai berikut:

  • Jika Anda menentukan kebijakan ini, izin token STS adalah irisan dari izin yang diberikan ke Peran RAM dan izin yang ditentukan dalam kebijakan ini.

  • Jika Anda tidak menentukan kebijakan ini, token STS memiliki semua izin yang diberikan ke Peran RAM.

Nilai harus memiliki panjang 1 hingga 2.048 karakter.

url_encoded_policy

DurationSeconds

integer

No

Durasi kedaluwarsa token. Unit: detik.

Nilai minimum adalah 900 detik. Nilai maksimum adalah nilai parameter MaxSessionDuration. Nilai default adalah 3600 detik.

Anda dapat mengatur parameter MaxSessionDuration saat memanggil operasi CreateRole atau UpdateRole. Untuk informasi selengkapnya, lihat CreateRole atau UpdateRole.

3600

Catatan

Karena operasi AssumeRoleWithSAML menggunakan pernyataan SAML untuk autentikasi identitas dan mengizinkan akses anonim, Anda tidak perlu menentukan parameter permintaan umum Signature, SignatureMethod, SignatureVersion, atau AccessKeyId. Untuk informasi selengkapnya tentang parameter permintaan umum, lihat Parameter permintaan umum.

Elemen respons

Element

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 urn:oasis:names:tc:SAML:2.0:nameid-format:, the prefix is removed. Examples: persistent and transient.

persistent

Subject

string

The value of the Subject - NameID field in the SAML assertion.

alice@example.com

Issuer

string

The value of the Issuer field in the SAML assertion.

http://example.com/adfs/services/trust

Recipient

string

The value of the Recipient attribute in the Subject - SubjectConfirmation - SubjectConfirmationData field of the SAML assertion.

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.

Catatan

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

Contoh

Respons sukses

JSONformat

{
  "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"
}

Kode kesalahan

HTTP status code

Error code

Error message

Description

500 InternalError STS Server Internal Error happened, please send the RequestId to us.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.