設定驗證回應的 SAML 宣告 - AWS Identity and Access Management

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

設定驗證回應的 SAML 宣告

驗證組織中的使用者身分後,外部身分識別提供者 (IdP) 會將驗證回應傳送至位於的 AWS SAML 端點。https://region-code.signin.aws.amazon.com/saml對於可能的 region-code 替換清單,請參閱 AWS 登入端點中的 Region (區域) 欄位。此回應是一個包含 SAML 權杖的 POST 請求,該權杖遵循適用於 SAML 2.0 的 HTTP POST 繫結標準,其中包含下列元素或宣告。您可在與 SAML 相容的 IdP 中配置這些聲明。請參考 IdP 文件,以了解有關如何輸入這些聲明的說明。

當 IdP 將包含聲明的響應發送到時 AWS,許多傳入的聲明映射到 AWS 上下文鍵。可以在 IAM 政策中使用 Condition 元素來檢查這些內容索引鍵。可用映射的清單將根據 將 SAML 屬性對應至 AWS 信任原則內容索引鍵 中所示。

SubjectNameID

下列的摘錄顯示了範例。用您自己的值替代標記值。同時包含 SubjectConfirmationSubjectConfirmationData 屬性的 NotOnOrAfter 元素必須恰好具有一個 Recipient 元素。這些屬性包括必須與 AWS 端點相符的值https://region-code.signin.aws.amazon.com/saml。對於可能的 region-code 值清單,請參閱 AWS 登入端點中的 Region (區域) 欄位。對於 AWS 值,您也可以使用https://signin.aws.amazon.com/static/saml,如下列範例所示。

NameID 元素的值可以是持久的、暫時的,也可以由 IdP 解決方案提供的完整格式 URI 組成。持久的值表示 NameID 中的值對於工作階段之間的使用者是相同的。如果值為暫時的,則使用者在每個工作階段中擁有不同的 NameID 值。單一登入互動支援下列類型的識別碼:

  • urn:oasis:names:tc:SAML:2.0:nameid-format:persistent

  • urn:oasis:names:tc:SAML:2.0:nameid-format:transient

  • urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress

  • urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified

  • urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName

  • urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName

  • urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos

  • urn:oasis:names:tc:SAML:2.0:nameid-format:entity

<Subject> <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">_cbb88bf52c2510eabe00c1642d4643f41430fe25e3</NameID> <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> <SubjectConfirmationData NotOnOrAfter="2013-11-05T02:06:42.876Z" Recipient="https://signin.aws.amazon.com/saml"/> </SubjectConfirmation> </Subject>
重要

saml:aud 內容索引鍵來自 SAML recipient 屬性,因其為等同於 OIDC 觀眾欄位 (例如 accounts.google.com:aud) 的 SAML。

PrincipalTag SAML 屬性

(選用) 您可以使用 Attribute 元素,並將 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/PrincipalTag:{TagKey}。此元素可讓您在 SAML 聲明中將屬性做為工作階段標籤傳遞。如需有關工作階段標籤的詳細資訊,請參閱 傳遞工作階段標籤 AWS STS

若要將屬性做為工作階段標籤傳遞,請包含指定標籤值的 AttributeValue 元素。例如,若要傳遞標籤金鑰/值對 Project = MarketingCostCenter = 12345,請使用以下屬性。為每個標籤包含個別的 Attribute 元素。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:Project"> <AttributeValue>Marketing</AttributeValue> </Attribute> <Attribute Name="https://aws.amazon.com/SAML/Attributes/PrincipalTag:CostCenter"> <AttributeValue>12345</AttributeValue> </Attribute>

如要將以上標籤設為可轉移,請在其中包含另一個 Attribute 元素,並將其 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/TransitiveTagKeys。這是一個選用的多重值屬性,會將您的工作階段標籤設為可轉移。可轉移標籤會在您於 AWS中使用 SAML 聲明擔任另一個角色時保存。這就是所謂的角色鏈接。例如,若要將 PrincipalCostCenter 標籤設為可轉移,請使用以下屬性來指定金鑰。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/TransitiveTagKeys"> <AttributeValue>Project</AttributeValue> <AttributeValue>CostCenter</AttributeValue> </Attribute>

Role SAML 屬性

您可以使用 Attribute 元素,將 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/Role。此元素包含一或多個 AttributeValue 元素,這些元素可列出將由您的 IdP 對應之使用者的 IAM 身分提供者和角色。IAM 角色和 IAM 身分識別提供者會以逗號分隔的 ARN 組指定,格式與傳送至 AssumeRoleWith SAML 的RoleArnPrincipalArn參數相同。此元素必須包含至少一個角色提供者對 (AttributeValue 元素),並且可以包含多個角色提供者對。如果該元素包含多個角色提供者組,則使用者將需要選擇其使用 WebSSO 登入 AWS Management Console時要擔任的角色。

重要

Name 標籤中 Attribute 屬性的值區分大小寫。必須精準設定為 https://aws.amazon.com/SAML/Attributes/Role

<Attribute Name="https://aws.amazon.com/SAML/Attributes/Role"> <AttributeValue>arn:aws:iam::account-number:role/role-name1,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> <AttributeValue>arn:aws:iam::account-number:role/role-name2,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> <AttributeValue>arn:aws:iam::account-number:role/role-name3,arn:aws:iam::account-number:saml-provider/provider-name</AttributeValue> </Attribute>

RoleSessionName SAML 屬性

您可以使用 Attribute 元素,將 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/RoleSessionName。此元素包含一個為暫時憑證提供識別符的 AttributeValue 元素,而這些憑證是在擔任角色時所發出。您可以使用此功能將臨時憑證與正在使用應用程式的使用者建立關聯。此元素用於在中顯示使用者資訊 AWS Management Console。AttributeValue 元素中的值長度必須介於 2 到 64 個字元之間,只能包含字母數位字元、底線和以下字元:. , + = @ - (連字號)。其中不可含有空格。該值通常是使用者 ID (johndoe) 或電子郵件地址 (johndoe@example.com)。該值不應包含空格,如使用者的顯示名稱 (John Doe)。

重要

Name 標籤中 Attribute 屬性的值區分大小寫。必須精準設定為 https://aws.amazon.com/SAML/Attributes/RoleSessionName

<Attribute Name="https://aws.amazon.com/SAML/Attributes/RoleSessionName"> <AttributeValue>user-id-name</AttributeValue> </Attribute>

SessionDuration SAML 屬性

(選用) 您可以使用 Attribute 元素,並將 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/SessionDuration"。此元素包含一個AttributeValue元素,指定使用者在必須要求新的臨時認證 AWS Management Console 之前可以存取的時間長度。該值是一個表示工作階段秒數的整數。該值的範圍是 900 秒 (15 分鐘) 到 43200 秒 (12 小時)。如果此屬性不存在,則憑證有效時間為 1 小時 (DurationSeconds API 的 AssumeRoleWithSAML 參數的預設值)。

若要使用此屬性,您必須將 SAML 提供者設定為 AWS Management Console 透過主控台登入 Web 端點提供單一登入存取權限。https://region-code.signin.aws.amazon.com/saml對於可能的 region-code 值清單,請參閱 AWS 登入端點中的 Region (區域) 欄位。您可以選擇使用以下 URL:https://signin.aws.amazon.com/static/saml。請注意,此屬性只會將工作階段擴展到 AWS Management Console。它不能延長其他憑證的有效期。但是,如果其存在於 AssumeRoleWithSAML API 呼叫中,則可以用來縮短工作階段的持續時間。呼叫傳回的憑證預設存留期是 60 分鐘。

另請注意,如果同時定義 SessionNotOnOrAfter 屬性,則兩個屬性的較小值 (SessionDurationSessionNotOnOrAfter) 將建立主控台工作階段的最長持續時間。

在啟用具有更長持續時間的主控台工作階段時,可能會導致憑證洩露的風險。為了幫助緩解這種風險,您可以在 IAM 主控台的 Role Summary (角色摘要) 頁面上選擇 Revoke Sessions (撤銷工作階段) 來立即停用所有角色的使用中的主控台工作階段。如需詳細資訊,請參閱 撤銷 IAM 角色暫時性安全憑證

重要

Name 標籤中 Attribute 屬性的值區分大小寫。必須精準設定為 https://aws.amazon.com/SAML/Attributes/SessionDuration

<Attribute Name="https://aws.amazon.com/SAML/Attributes/SessionDuration"> <AttributeValue>1800</AttributeValue> </Attribute>

SourceIdentity SAML 屬性

(選用) 您可以使用 Attribute 元素,並將 Name 屬性設為 https://aws.amazon.com/SAML/Attributes/SourceIdentity。此元素包含一個 AttributeValue 元素,提供使用 IAM 角色之人員或應用程式的識別碼。當您使用 SAML 工作階段在 AWS 稱為角色鏈結中擔任另一個角色時,來源識別的值仍然存在。針對在角色工作階段期間所採取的每個動作,來源身分的值會出現在請求中。設定的值無法在角色工作階段期間變更。然後,系統管理員可以使用 AWS CloudTrail 記錄來監視和稽核來源身分識別資訊,以決定誰使用共用角色執行動作。

AttributeValue 元素中的值長度必須介於 2 到 64 個字元之間,只能包含字母數位字元、底線和以下字元:. , + = @ - (連字號)。其中不可含有空格。此值通常是與使用者相關聯的屬性,例如使用者 ID (johndoe) 或電子郵件地址 (johndoe@example.com)。該值不應包含空格,如使用者的顯示名稱 (John Doe)。如需有關使用來源身分的詳細資訊,請參閱 監控並控制使用擔任角色所採取的動作

重要

如果您的 SAML 聲明設定為使用 SourceIdentity 屬性,則您的信任政策也必須包含 sts:SetSourceIdentity 動作,否則擔任角色操作將失敗。如需有關使用來源身分的詳細資訊,請參閱 監控並控制使用擔任角色所採取的動作

若要傳遞來源身分屬性,請包含指定來源身分值的 AttributeValue 元素。例如,若要傳遞來源身分 DiegoRamirez,請使用下列屬性。

<Attribute Name="https://aws.amazon.com/SAML/Attributes/SourceIdentity"> <AttributeValue>DiegoRamirez</AttributeValue>

將 SAML 屬性對應至 AWS 信任原則內容索引鍵

本部分中的表列出了常用的 SAML 屬性以及它們在 AWS中映射到信任政策條件內容索引鍵的方式。您可以使用這些金鑰來控制角色的存取。若要執行此作業,請將金鑰與包含在 SAML 存取請求隨附聲明中的值進行比較。

重要

這些索引鍵僅在 IAM 信任政策 (可決定誰能擔任角色的政策) 中可用,並且不適用於許可政策。

在 eduPerson 和 eduOrg 屬性工作表中,值是以字串或字串清單的形式輸入的。對於字串值,您可以使用 StringEqualsStringLike 條件測試 IAM 信任政策中的這些值。對於包含字串清單的值,您可以使用 ForAnyValueForAllValues 政策集運算子來測試信任政策中的這些值。

注意

每個內容索引 AWS 鍵應該只包含一個宣告。如果包含多個聲明,將僅映射其中一個。

eduPerson 和 eduOrg 屬性
eduPerson 或 eduOrg 屬性 (Name 索引鍵) 映射到此 AWS 上下文鍵(FriendlyName鍵) 類型

urn:oid:1.3.6.1.4.1.5923.1.1.1.1

eduPersonAffiliation

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.2

eduPersonNickname

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.3

eduPersonOrgDN

字串

urn:oid:1.3.6.1.4.1.5923.1.1.1.4

eduPersonOrgUnitDN

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.5

eduPersonPrimaryAffiliation

字串

urn:oid:1.3.6.1.4.1.5923.1.1.1.6

eduPersonPrincipalName

字串

urn:oid:1.3.6.1.4.1.5923.1.1.1.7

eduPersonEntitlement

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.8

eduPersonPrimaryOrgUnitDN

字串

urn:oid:1.3.6.1.4.1.5923.1.1.1.9

eduPersonScopedAffiliation

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.10

eduPersonTargetedID

字串清單

urn:oid:1.3.6.1.4.1.5923.1.1.1.11

eduPersonAssurance

字串清單

urn:oid:1.3.6.1.4.1.5923.1.2.1.2

eduOrgHomePageURI

字串清單

urn:oid:1.3.6.1.4.1.5923.1.2.1.3

eduOrgIdentityAuthNPolicyURI

字串清單

urn:oid:1.3.6.1.4.1.5923.1.2.1.4

eduOrgLegalName

字串清單

urn:oid:1.3.6.1.4.1.5923.1.2.1.5

eduOrgSuperiorURI

字串清單

urn:oid:1.3.6.1.4.1.5923.1.2.1.6

eduOrgWhitePagesURI

字串清單

urn:oid:2.5.4.3

cn

字串清單

Active Directory 屬性
AD 屬性 映射到此 AWS 上下文鍵 Type

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name

name

字串

http://schemas.xmlsoap.org/claims/CommonName

commonName

字串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname

givenName

字串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname

surname

字串

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress

mail

字串

http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid

uid

字串

X.500 屬性
X.500 屬性 映射到此 AWS 上下文鍵 Type

2.5.4.3

commonName

字串

2.5.4.4

surname

字串

2.4.5.42

givenName

字串

2.5.4.45

x500UniqueIdentifier

字串

0.9.2342.19200300100.1.1

uid

字串

0.9.2342.19200300100.1.3

mail

字串

0.9.2342.19200300.100.1.45

organizationStatus

字串