SAML 權杖宣告參考

Microsoft 身分識別平台 會在處理每個驗證流程時發出數種類型的安全性令牌。 本文件說明 SAML 2.0 令牌的格式、安全性特性和內容。

SAML 權杖中的宣告

名稱 對等 JWT 宣告 描述 範例
受眾 aud 令牌的預期收件者。 接收令牌的應用程式必須確認物件值正確,並拒絕任何適用於不同物件之令牌。 <AudienceRestriction>
<Audience>
https://contoso.com
</Audience>
</AudienceRestriction>
驗證時刻 記錄驗證發生的日期和時間。 <AuthnStatement AuthnInstant="2011-12-29T05:35:22.000Z">
驗證方法 amr 識別令牌主體的驗證方式。 <AuthnContextClassRef>
http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod/password
</AuthnContextClassRef>
名字 given_name 提供使用者的第一個或「指定」名稱,如 Microsoft Entra 用戶物件上所設定。 <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
<AttributeValue>Frank<AttributeValue>
群組 groups 提供代表主體群組成員資格的物件標識符。 這些值是唯一的(請參閱對象標識符),而且可以安全地用於管理存取,例如強制執行存取資源的授權。 群組宣告中包含的群組會透過應用程式指令清單的 「groupMembershipClaims」 屬性,根據每個應用程式設定。 Null 值會排除所有群組、“SecurityGroup” 的值會包含目錄角色和 Active Directory 安全組成員資格,而 “All” 的值將同時包含安全組和 Microsoft 365 通訊組清單。

注意
如果使用者所進入的群組數目超過限制 (SAML 為 150,JWT 為 200),則會新增超額宣告來源,指向包含使用者群組清單的 Graph 端點。
<Attribute Name="http://schemas.microsoft.com/ws/2008/06/identity/claims/groups">
<AttributeValue>07dd8a60-bf6d-4e17-8844-230b77145381</AttributeValue>
群組超額指標 groups:src1 對於長度不受限但對令牌而言仍然太大的令牌要求,將會包含使用者的完整群組清單連結。 針對 SAML,這會新增為取代宣告的新宣告 groups

注意
Azure AD Graph API 正由 Microsoft Graph API 取代。 若要深入瞭解對等端點,請參閱 使用者:getMemberObjects
<Attribute Name=" http://schemas.microsoft.com/claims/groups.link">
<AttributeValue>https://graph.windows.net/{tenantID}/users/{userID}/getMemberObjects<AttributeValue>
身分識別提供者 idp 記錄驗證權杖主體的身分識別提供者。 這個值與簽發者宣告的值相同,除非用戶帳戶位於與簽發者不同的租使用者中。 <Attribute Name=" http://schemas.microsoft.com/identity/claims/identityprovider">
<AttributeValue>https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/<AttributeValue>
IssuedAt iat 儲存發出令牌的時間。 它通常用來測量令牌的新鮮度。 <Assertion ID="_d5ec7a9b-8d8f-4b44-8c94-9812612142be" IssueInstant="2014-01-06T20:20:23.085Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
簽發者 iss 識別建構及傳回令牌的安全性令牌服務 (STS)。 在 Microsoft Entra ID 傳回的令牌中,簽發者會 sts.windows.net。 簽發者宣告值中的 GUID 是 Microsoft Entra 目錄的租用戶標識碼。 租用戶標識碼是目錄的不可變且可靠的標識碼。 <Issuer>https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/</Issuer>
姓氏 family_name 提供 Microsoft Entra 用戶物件中所定義之使用者的姓氏、姓氏或姓氏。 <Attribute Name=" http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname">
<AttributeValue>Miller<AttributeValue>
名稱 unique_name 提供人類看得懂的值,用以識別權杖的主體。 此值不保證在租使用者內是唯一的,而且設計為僅供顯示之用。 <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
<AttributeValue>frankm@contoso.com<AttributeValue>
物件識別碼 oid 包含 Microsoft Entra ID 中物件的唯一標識碼。 這個值是不可變的,無法重新指派或重複使用。 使用物件標識碼來識別查詢中的物件至 Microsoft Entra ID。 <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
<AttributeValue>528b2ac2-aa9c-45e1-88d4-959b53bc7dd0<AttributeValue>
角色 roles 代表主體透過群組成員資格直接或間接授與的所有應用程式角色,並可用來強制執行角色型訪問控制。 應用程式角色是透過 appRoles 應用程式指令清單的屬性,依個別應用程式定義。 value每個應用程式角色的 屬性都是出現在角色宣告中的值。 <Attribute Name="http://schemas.microsoft.com/ws/2008/06/identity/claims/role">
主體 sub 識別令牌判斷提示信息的主體,例如應用程式的使用者。 這個值是不可變的,無法重新指派或重複使用,因此可用來安全地執行授權檢查。 由於主體一律存在於 Microsoft Entra ID 問題的令牌中,因此建議在一般用途授權系統中使用此值。
SubjectConfirmation 不是宣告。 它描述令牌主體的驗證方式。 Bearer 表示主體是由其擁有令牌來確認。
<Subject>
<NameID>S40rgb3XjhFTv6EQTETkEzcgVmToHKRkZUIsJlmLdVc</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer" />
</Subject>
租用戶識別碼 tid 不可變且不可重複使用的識別碼,可識別發出令牌的目錄租使用者。 您可以使用此值來存取多租使用者應用程式中的租使用者特定目錄資源。 例如,您可以使用此值來識別圖形 API 呼叫中的租使用者。 <Attribute Name="http://schemas.microsoft.com/identity/claims/tenantid">
<AttributeValue>aaaabbbb-0000-cccc-1111-dddd2222eeee<AttributeValue>
權杖存留期 nbf, exp 定義權杖有效的時間間隔。 驗證令牌的服務應該確認目前日期在令牌存留期內,否則應該拒絕令牌。 此服務最多允許超過令牌存留期範圍五分鐘,以考慮 Microsoft Entra ID 與服務之間的時鐘時間(“時間扭曲”)的任何差異。 <Conditions
NotBefore="2013-03-18T21:32:51.261Z"
NotOnOrAfter="2013-03-18T22:32:51.261Z"
>

SAML 令牌範例

這是一般SAML令牌的範例。

<?xml version="1.0" encoding="UTF-8"?>
<t:RequestSecurityTokenResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
    <t:Lifetime>
        <wsu:Created xmlns:wsu="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2014-12-24T05:15:47.060Z</wsu:Created>
        <wsu:Expires xmlns:wsu="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2014-12-24T06:15:47.060Z</wsu:Expires>
    </t:Lifetime>
    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <EndpointReference xmlns="https://www.w3.org/2005/08/addressing">
            <Address>https://contoso.onmicrosoft.com/MyWebApp</Address>
        </EndpointReference>
    </wsp:AppliesTo>
    <t:RequestedSecurityToken>
        <Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_3ef08993-846b-41de-99df-b7f3ff77671b" IssueInstant="2014-12-24T05:20:47.060Z" Version="2.0">
            <Issuer>https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/</Issuer>
            <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="https://www.w3.org/2001/10/xml-exc-c14n#" />
                    <ds:SignatureMethod Algorithm="https://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
                    <ds:Reference URI="#_3ef08993-846b-41de-99df-b7f3ff77671b">
                        <ds:Transforms>
                            <ds:Transform Algorithm="https://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                            <ds:Transform Algorithm="https://www.w3.org/2001/10/xml-exc-c14n#" />
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="https://www.w3.org/2001/04/xmlenc#sha256" />
                        <ds:DigestValue>cV1J580U1pD24hEyGuAxrbtgROVyghCqI32UkER/nDY=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>j+zPf6mti8Rq4Kyw2NU2nnu0pb{lots of characters}ut93UTyTAIGOs5fvP9ZfK2vNeMVJW7Xg==</ds:SignatureValue>
                <KeyInfo xmlns="https://www.w3.org/2000/09/xmldsig#">
                    <X509Data>
                        <X509Certificate>MIIDPjCCAabcAwIBAgIQsRiM0jheFZhKk49YD0SK1TAJBgUrDg{lots of characters}OBcXWLAIarZ</X509Certificate>
                    </X509Data>
                </KeyInfo>
            </ds:Signature>
            <Subject>
                <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">m_H3naDei2LNxUmEcWd0BZlNi_jVET1pMLR6iQSuYmo</NameID>
                <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer" />
            </Subject>
            <Conditions NotBefore="2014-12-24T05:15:47.060Z" NotOnOrAfter="2014-12-24T06:15:47.060Z">
                <AudienceRestriction>
                    <Audience>https://contoso.onmicrosoft.com/MyWebApp</Audience>
                </AudienceRestriction>
            </Conditions>
            <AttributeStatement>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
                    <AttributeValue>aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/tenantid">
                    <AttributeValue>aaaabbbb-0000-cccc-1111-dddd2222eeee</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
                    <AttributeValue>sample.admin@contoso.onmicrosoft.com</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname">
                    <AttributeValue>Admin</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname">
                    <AttributeValue>Sample</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.microsoft.com/ws/2008/06/identity/claims/groups">
                    <AttributeValue>5581e43f-6096-41d4-8ffa-04e560bab39d</AttributeValue>
                    <AttributeValue>07dd8a89-bf6d-4e81-8844-230b77145381</AttributeValue>
                    <AttributeValue>0e129f4g-6b0a-4944-982d-f776000632af</AttributeValue>
                    <AttributeValue>3ee07328-52ef-4739-a89b-109708c22fb5</AttributeValue>
                    <AttributeValue>329k14b3-1851-4b94-947f-9a4dacb595f4</AttributeValue>
                    <AttributeValue>6e32c650-9b0a-4491-b429-6c60d2ca9a42</AttributeValue>
                    <AttributeValue>f3a169a7-9a58-4e8f-9d47-b70029v07424</AttributeValue>
                    <AttributeValue>8e2c86b2-b1ad-476d-9574-544d155aa6ff</AttributeValue>
                    <AttributeValue>1bf80264-ff24-4866-b22c-6212e5b9a847</AttributeValue>
                    <AttributeValue>4075f9c3-072d-4c32-b542-03e6bc678f3e</AttributeValue>
                    <AttributeValue>76f80527-f2cd-46f4-8c52-8jvd8bc749b1</AttributeValue>
                    <AttributeValue>0ba31460-44d0-42b5-b90c-47b3fcc48e35</AttributeValue>
                    <AttributeValue>edd41703-8652-4948-94a7-2d917bba7667</AttributeValue>
                </Attribute>
                <Attribute Name="http://schemas.microsoft.com/identity/claims/identityprovider">
                    <AttributeValue>https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/</AttributeValue>
                </Attribute>
            </AttributeStatement>
            <AuthnStatement AuthnInstant="2014-12-23T18:51:11.000Z">
                <AuthnContext>
                    <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
                </AuthnContext>
            </AuthnStatement>
        </Assertion>
    </t:RequestedSecurityToken>
    <t:RequestedAttachedReference>
        <SecurityTokenReference xmlns="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:d3p1="https://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" d3p1:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
            <KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID">_3ef08993-846b-41de-99df-b7f3ff77671b</KeyIdentifier>
        </SecurityTokenReference>
    </t:RequestedAttachedReference>
    <t:RequestedUnattachedReference>
        <SecurityTokenReference xmlns="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:d3p1="https://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" d3p1:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
            <KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID">_3ef08993-846b-41de-99df-b7f3ff77671b</KeyIdentifier>
        </SecurityTokenReference>
    </t:RequestedUnattachedReference>
    <t:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</t:TokenType>
    <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
    <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
</t:RequestSecurityTokenResponse>

下一步