シングル サインオンの SAML プロトコル

この記事では、Microsoft Entra ID がシングル サインオン (SSO) に対してサポートする SAML 2.0 の認証要求と応答について説明します。

次の図は、このプロトコルでのシングル サインオンのシーケンスを示したものです。 クラウド サービス (サービス プロバイダー) は、HTTP リダイレクト バインディングを使用して、 AuthnRequest (認証要求) 要素を Microsoft Entra ID (ID プロバイダー) に渡します。 Microsoft Entra ID は、HTTP POST バインディングを使用して、Response 要素をクラウド サービスに送信します。

Screenshot of the Single Sign-On (SSO) Workflow.

Note

この記事では、シングル サインオンでの SAML の使用について説明します。 シングル サインオンを処理するその他の方法 (OpenID Connect や統合 Windows 認証など) の詳細については、Microsoft Entra ID でのアプリケーションへのシングル サインオンに関するページを参照してください。

AuthnRequest

ユーザー認証を要求するため、クラウド サービスは AuthnRequest 要素を Microsoft Entra ID に送信します。 サンプル SAML 2.0 AuthnRequest は次の例のようになります。

<samlp:AuthnRequest
  xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
  ID="id6c1c178c166d486687be4aaf5e482730"
  Version="2.0" IssueInstant="2013-03-18T03:28:54.1839884Z"
  xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://www.contoso.com</Issuer>
</samlp:AuthnRequest>
パラメーター Type 内容
ID 必須 Microsoft Entra ID はこの属性を使用して、返される応答の InResponseTo 属性を設定します。 ID の 1 文字目に数字を使用することはできないので、一般的な方法としては、GUID の文字列表現の前に "ID" のような文字列を付加します。 たとえば、 id6c1c178c166d486687be4aaf5e482730 は有効な ID です。
Version 必須 このパラメーターは 2.0 に設定する必要があります。
IssueInstant 必須 これは、UTC 値と ラウンドトリップ書式 ("o")の DateTime 文字列です。 Microsoft Entra ID はこの型の DateTime 値を期待しますが、値を評価または使用することはありません。
AssertionConsumerServiceURL オプション 指定する場合、このパラメーターは Microsoft Entra ID でのクラウド サービスの RedirectUri と一致する必要があります。
ForceAuthn オプション これはブール値です。 true の場合は、ユーザーが Microsoft Entra ID で有効なセッションを持っている場合であっても、再認証を強制されることを意味します。
IsPassive オプション これはブール値で、セッション cookie がある場合はそれを使って、ユーザーの介入なしに、サイレント モードで Microsoft Entra ID がユーザーを認証する必要があるかどうかを指定します。 true の場合は、Microsoft Entra ID はセッション cookie を使ってユーザーの認証を試みます。

他のすべての AuthnRequest 属性 (ConsentDestinationAssertionConsumerServiceIndexAttributeConsumerServiceIndexProviderName など) は無視されます。

Microsoft Entra ID では、AuthnRequest 内の Conditions 要素も無視されます。

発行者

AuthnRequestIssuer 要素は、Microsoft Entra ID でのクラウド サービスの ServicePrincipalNames のいずれかと厳密に一致する必要があります。 通常、これはアプリケーション登録時に指定される App ID URI に設定されます。

次のサンプルは、Issuer 要素を含む SAML の抜粋です。

<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://www.contoso.com</Issuer>

NameIDPolicy

この要素は、特定の名前 ID 形式を応答で使用することを要求するものであり、Microsoft Entra ID に送信される AuthnRequest 要素では省略可能です。

NameIdPolicy 要素は次のサンプルのようになります。

<NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"/>

NameIDPolicy を指定する場合は、省略可能な Format 属性を含めることができます。 Format 属性で指定できる値は次のいずれかのみであり、それ以外の値はエラーになります。

  • urn:oasis:names:tc:SAML:2.0:nameid-format:persistent: Microsoft Entra ID は、NameIDペアワイズ識別子として要求を発行します。
  • urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress: Microsoft Entra ID は、NameIDメール アドレス形式で要求を発行します。
  • urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified: この値は、Microsoft Entra ID が要求の形式を選択することを許可します。 Microsoft Entra ID は、NameIDペアワイズ識別子として要求を発行します。
  • urn:oasis:names:tc:SAML:2.0:nameid-format:transient: Microsoft Entra ID は、NameID現在の SSO 操作に固有となる無作為に生成された値として NameID 要求を発行します。 つまり、値は一時的であり、認証ユーザーの識別に使うことはできません。

SPNameQualifier が指定されている場合、Microsoft Entra ID には同じ SPNameQualifier が応答に含まれます。

Microsoft Entra ID は AllowCreate 属性を無視します。

RequestedAuthnContext

RequestedAuthnContext 要素は、必要な認証方法を指定します。 Microsoft Entra ID に送信される AuthnRequest 要素では省略可能です。 Microsoft Entra ID では、urn:oasis:names:tc:SAML:2.0:ac:classes:Password などの AuthnContextClassRef 値がサポートされます。

Scoping

ID プロバイダーのリストが含まれる Scoping 要素は、Microsoft Entra ID に送信される AuthnRequest 要素では省略可能です。

指定する場合は、ProxyCount 属性、IDPListOption 要素、または RequesterID 要素を使用しないでください。これらはサポートされていません。

署名

AuthnRequest 要素内の Signature 要素は省略可能です。 署名された認証要求の要件を実行するように Microsoft Entra ID を構成できます。 有効にした場合は、署名された認証要求のみが受け入れられます。それ以外の場合、要求元の検証は、登録されている Assertion Consumer Service の URL に応答することによってのみ提供されます。

サブジェクト

Subject 要素を含めないでください。 Microsoft Entra ID は、AuthnRequest のサブジェクトの指定をサポートしていません。指定した場合は、エラーが返されます。

代わりに、パラメーター値としてサブジェクトの NameID を使用して、シングル サインオン URL への HTTP 要求に login_hint パラメーターを追加することで、サブジェクトを指定できます。

回答

要求されたサインオンが正常に完了すると、Microsoft Entra ID はクラウド サービスに応答を送信します。 サインオンに成功した場合、次のサンプルのような応答が返されます。

<samlp:Response ID="_a4958bfd-e107-4e67-b06d-0d85ade2e76a" Version="2.0" IssueInstant="2013-03-18T07:38:15.144Z" Destination="https://contoso.com/identity/inboundsso.aspx" InResponseTo="id758d0ef385634593a77bdf7e632984b6" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
  <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
    ...
  </ds:Signature>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
  </samlp:Status>
  <Assertion ID="_bf9c623d-cc20-407a-9a59-c2d0aee84d12" IssueInstant="2013-03-18T07:38:15.144Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
    <Issuer>https://login.microsoftonline.com/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
    <ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
      ...
    </ds:Signature>
    <Subject>
      <NameID>Uz2Pqz1X7pxe4XLWxV9KJQ+n59d573SepSAkuYKSde8=</NameID>
      <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <SubjectConfirmationData InResponseTo="id758d0ef385634593a77bdf7e632984b6" NotOnOrAfter="2013-03-18T07:43:15.144Z" Recipient="https://contoso.com/identity/inboundsso.aspx" />
      </SubjectConfirmation>
    </Subject>
    <Conditions NotBefore="2013-03-18T07:38:15.128Z" NotOnOrAfter="2013-03-18T08:48:15.128Z">
      <AudienceRestriction>
        <Audience>https://www.contoso.com</Audience>
      </AudienceRestriction>
    </Conditions>
    <AttributeStatement>
      <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
        <AttributeValue>testuser@contoso.com</AttributeValue>
      </Attribute>
      <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
        <AttributeValue>3F2504E0-4F89-11D3-9A0C-0305E82C3301</AttributeValue>
      </Attribute>
      ...
    </AttributeStatement>
    <AuthnStatement AuthnInstant="2013-03-18T07:33:56.000Z" SessionIndex="_bf9c623d-cc20-407a-9a59-c2d0aee84d12">
      <AuthnContext>
        <AuthnContextClassRef> urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
      </AuthnContext>
    </AuthnStatement>
  </Assertion>
</samlp:Response>

Response

Response 要素には、承認要求の結果が含まれます。 Microsoft Entra ID では、Response 要素に ID 値、Version 値、IssueInstant 値が設定されます。 また、次の属性も設定します。

  • Destination:サインオンが正常に完了すると、サービス プロバイダー (クラウド サービス) の RedirectUri が設定されます。
  • InResponseTo:応答を開始した AuthnRequest 要素の ID 属性が設定されます。

発行者

Microsoft Entra ID は、Issuer 要素を https://sts.windows.net/<TenantIDGUID>/ に設定します。<TenantIDGUID> は Microsoft Entra テナントのテナント ID です。

たとえば、Issuer 要素を含む応答の例は次のようになります。

<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> https://sts.windows.net/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>

Status

Status 要素には、サインオンの成功または失敗を示す値が設定されます。 StatusCode 要素が含まれており、この要素には要求の状態を表すコードまたは一連の入れ子になったコードが含まれます。 また、 StatusMessage 要素もあり、これにはサインイン プロセス中に生成されたカスタム エラー メッセージが含まれます。

サインオンに失敗した場合、次のような SAML 応答が返されます。

<samlp:Response ID="_f0961a83-d071-4be5-a18c-9ae7b22987a4" Version="2.0" IssueInstant="2013-03-18T08:49:24.405Z" InResponseTo="iddce91f96e56747b5ace6d2e2aa9d4f8c" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">https://sts.windows.net/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester">
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported" />
    </samlp:StatusCode>
    <samlp:StatusMessage>AADSTS75006: An error occurred while processing a SAML2 Authentication request. AADSTS90011: The SAML authentication request property 'NameIdentifierPolicy/SPNameQualifier' is not supported.
    Trace ID: 66febed4-e737-49ff-ac23-464ba090d57c
    Timestamp: 2013-03-18 08:49:24Z</samlp:StatusMessage>
    </samlp:Status>
</samlp:Response>

Assertion

IDIssueInstant、および Version に加えて、Microsoft Entra ID は応答の Assertion 要素の次の要素も設定します。

発行者

これは https://sts.windows.net/<TenantIDGUID>/ に設定されます。ここで、<TenantIDGUID> は Microsoft Entra テナントのテナント ID です。

<Issuer>https://sts.windows.net/82869000-6ad1-48f0-8171-272ed18796e9/</Issuer>

署名

Microsoft Entra ID は、サインオンが成功すると応答のアサーションに署名します。 Signature 要素にはデジタル署名が含まれ、クラウド サービスはそれを使用してソースを認証し、アサーションの整合性を検証できます。

このデジタル署名を生成するため、Microsoft Entra ID はメタデータ ドキュメントの IDPSSODescriptor 要素の署名キーを使用します。

<ds:Signature xmlns:ds="https://www.w3.org/2000/09/xmldsig#">
  digital_signature_here
</ds:Signature>

サブジェクト

これによって、アサーションのステートメントのサブジェクトであるプリンシパルを指定します。 認証されたユーザーを表す NameID 要素が含まれます。 NameID の値は、トークンの対象であるサービス プロバイダーに対してのみ送信される限定的な識別子です。 永続的であり、取り消すことはできますが、再割り当てはされません。 また、非透過的であるため、ユーザーについての情報はわからず、属性クエリに対する識別子としては使用できません。

SubjectConfirmation 要素の Method 属性は、常に urn:oasis:names:tc:SAML:2.0:cm:bearer に設定されます。

<Subject>
  <NameID>Uz2Pqz1X7pxe4XLWxV9KJQ+n59d573SepSAkuYKSde8=</NameID>
  <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
    <SubjectConfirmationData InResponseTo="id758d0ef385634593a77bdf7e632984b6" NotOnOrAfter="2013-03-18T07:43:15.144Z" Recipient="https://contoso.com/identity/inboundsso.aspx" />
  </SubjectConfirmation>
</Subject>

条件

この要素は、SAML アサーションの許容される使用方法を定義する条件を指定します。

<Conditions NotBefore="2013-03-18T07:38:15.128Z" NotOnOrAfter="2013-03-18T08:48:15.128Z">
  <AudienceRestriction>
    <Audience>https://www.contoso.com</Audience>
  </AudienceRestriction>
</Conditions>

NotBefore および NotOnOrAfter 属性は、アサーションが有効である期間を指定します。

  • NotBefore 属性の値は、Assertion 要素の IssueInstant 属性と同じか、またはそれよりもわずかに (1 秒未満) 後です。 Microsoft Entra ID では、それ自体とクラウド サービス (サービス プロバイダー) 間の時間の違いは考慮されず、この時間に対するバッファーは追加されません。
  • NotOnOrAfter 属性の値は、NotBefore 属性の値より 70 分後です。

対象ユーザー

この要素には、対象を識別する URI が含まれます。 Microsoft Entra ID は、この要素の値に、サインオンを開始した AuthnRequestIssuer 要素の値を設定します。 Audience の値を評価するには、アプリケーション登録時に指定された App ID URI の値を使用します。

<AudienceRestriction>
  <Audience>https://www.contoso.com</Audience>
</AudienceRestriction>

Issuer の値と同様に、Audience の値は Microsoft Entra ID でクラウド サービスを表すサービス プリンシパル名のいずれかと厳密に一致する必要があります。 ただし、Issuer 要素の値が URI 値ではない場合は、応答の Audience の値は、プレフィックス spn: が付加された Issuer 値になります。

AttributeStatement

この要素には、サブジェクトまたはユーザーに関する要求が含まれます。 AttributeStatement 要素の例を含む抜粋を次に示します。 省略記号は、要素が複数の属性および属性値を含むことができることを示します。

<AttributeStatement>
  <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
    <AttributeValue>testuser@contoso.com</AttributeValue>
  </Attribute>
  <Attribute Name="http://schemas.microsoft.com/identity/claims/objectidentifier">
    <AttributeValue>3F2504E0-4F89-11D3-9A0C-0305E82C3301</AttributeValue>
  </Attribute>
  ...
</AttributeStatement>
  • Name 要求 - Name 属性 (http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name) の値は、認証されたユーザーのユーザー プリンシパル名です (例: testuser@managedtenant.com)。
  • ObjectIdentifier 要求 - ObjectIdentifier 属性 (http://schemas.microsoft.com/identity/claims/objectidentifier) の値は、Microsoft Entra ID で認証されたユーザーを表すディレクトリ オブジェクトの ObjectId です。 ObjectId は、認証されたユーザーの変更不可能で、グローバルに一意であり、再利用が安全な識別子です。

AuthnStatement

この要素は、アサーション サブジェクトが特定の時刻に特定の手段によって認証されたことをアサートします。

  • AuthnInstant 属性は、Microsoft Entra ID でユーザーが認証された時刻を指定します。
  • AuthnContext 要素は、ユーザーの認証に使用された認証コンテキストを指定します。
<AuthnStatement AuthnInstant="2013-03-18T07:33:56.000Z" SessionIndex="_bf9c623d-cc20-407a-9a59-c2d0aee84d12">
  <AuthnContext>
    <AuthnContextClassRef> urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
  </AuthnContext>
</AuthnStatement>