LOCKED
ブログ一覧に戻る
SSO・IDaaSLOCKED MSO

SAML 2.0仕様書日本語詳解【RFC 7114準拠実装】

関連トピック: SAML認証の実装ガイド【仕様から設定まで完全解説】

SAML 2.0は、エンタープライズ認証の業界標準プロトコルです。本記事では、OASIS公式仕様の複雑な技術要件を、実装者向けに段階的に解説します。Assertion構造、署名・暗号化メカニズム、Binding方式、Profile定義、メタデータ交換まで、実装に必要なすべての知識を網羅します。

SAML 2.0の基本構成

SAML 2.0は、3つの主要コンポーネントから構成されます。

1. Assertion(アサーション)

AssertionはSAML認証の中核であり、ユーザー認証情報を表現するXML文書です。

<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
  Version="2.0"
  ID="_d71a3a8e9ee6e4fd0b3b1f9c0e8e5c7b"
  IssueInstant="2024-03-06T10:30:00Z">

  <saml:Issuer>https://idp.example.com</saml:Issuer>

  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <!-- XML署名 -->
  </ds:Signature>

  <saml:Subject>
    <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
      user@example.com
    </saml:NameID>
    <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
      <saml:SubjectConfirmationData NotOnOrAfter="2024-03-06T11:30:00Z"
        Recipient="https://sp.example.com/acs"/>
    </saml:SubjectConfirmation>
  </saml:Subject>

  <saml:Conditions NotBefore="2024-03-06T10:25:00Z"
    NotOnOrAfter="2024-03-06T11:30:00Z">
    <saml:AudienceRestriction>
      <saml:Audience>https://sp.example.com</saml:Audience>
    </saml:AudienceRestriction>
  </saml:Conditions>

  <saml:AuthnStatement AuthnInstant="2024-03-06T10:30:00Z"
    SessionIndex="s23bdf1f8e9e2e3c5d4f9a1b2c3d4e5f6">
    <saml:AuthnContext>
      <saml:AuthnContextClassRef>
        urn:oasis:names:tc:SAML:2.0:ac:classes:Password
      </saml:AuthnContextClassRef>
    </saml:AuthnContext>
  </saml:AuthnStatement>

  <saml:AttributeStatement>
    <saml:Attribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
      <saml:AttributeValue>user@example.com</saml:AttributeValue>
    </saml:Attribute>
    <saml:Attribute Name="givenName">
      <saml:AttributeValue>太郎</saml:AttributeValue>
    </saml:Attribute>
    <saml:Attribute Name="sn">
      <saml:AttributeValue>山田</saml:AttributeValue>
    </saml:Attribute>
  </saml:AttributeStatement>
</saml:Assertion>

Assertion内の主要要素

要素説明必須
IssuerIdPのエンティティIDはい
Subject認証対象ユーザーの識別子はい
SubjectConfirmationベアラートークン(HTTP POSTでの使用確認)はい
ConditionsAssertion有効期限(通常5分)はい
AuthnStatement認証時刻・方式(パスワード、MFA等)はい
AttributeStatementユーザー属性(メール、部門等)条件付き

2. Protocol(プロトコル)

ProtocolはAssertion交換の手順を定義します。

AuthnRequest:SPからIdPへ送信される認証要求

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
  xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
  ID="_8e8dc5f69a98cc4c1ff3427e5ce34606fd"
  Version="2.0"
  IssueInstant="2024-03-06T10:30:00Z"
  Destination="https://idp.example.com/sso"
  AssertionConsumerServiceURL="https://sp.example.com/acs">

  <saml:Issuer>https://sp.example.com</saml:Issuer>

  <samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
    AllowCreate="true"/>
</samlp:AuthnRequest>

Response:IdPからSPへ返信される認証応答

<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
  ID="_8e8dc5f69a98cc4c1ff3427e5ce34606fd"
  Version="2.0"
  IssueInstant="2024-03-06T10:31:00Z"
  Destination="https://sp.example.com/acs"
  InResponseTo="_8e8dc5f69a98cc4c1ff3427e5ce34606fd">

  <saml:Issuer>https://idp.example.com</saml:Issuer>

  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
  </samlp:Status>

  <saml:Assertion>
    <!-- Assertion本体 -->
  </saml:Assertion>
</samlp:Response>
RFPテンプレート(無料)

IDaaS導入RFPテンプレート

IDaaS導入の社内稟議に使えるRFPテンプレート。SSO、MFA、プロビジョニングなどの要件を網羅したフォーマットです。

無料でダウンロード

Binding方式:転送メカニズム

SAML Responseの転送方法は、複数の「Binding」方式が定義されています。

HTTP-POST Binding(最も推奨)

SPのACS(Assertion Consumer Service)URLへ、POSTリクエストでAssertionを送信します。

<form method="post" action="https://sp.example.com/acs">
  <input type="hidden" name="SAMLResponse"
    value="PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDOYWY6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24i..."/>
  <input type="hidden" name="RelayState" value="https://example.com/page"/>
  <input type="submit" value="Continue"/>
</form>

特徴

  • レスポンスが暗号化されていても、ブラウザ通信はTLS保護
  • ブックマーク後の再送信防止(POST-redirect-GET)
  • 最大4KBまでのデータ転送に対応

HTTP-Redirect Binding

SPのACS URLへ、GETリクエストでAssertionを送信します。

https://sp.example.com/acs?SAMLResponse=jVDPb%2BMEcwx4jFKr%2Fn5YxIwOAAA&RelayState=somevalue

特徴

  • URLに含めるため、データサイズが4KBに制限
  • ブラウザのアドレスバーに表示されるため、プライバシーリスク
  • Assertion署名は必須だが、暗号化は通常不要
  • 大規模属性情報を送信できない

署名・暗号化メカニズム

XML署名(W3C xmldsig)

AssertionおよびResponseに対して、デジタル署名を施すことで、改ざん検知と発信者認証を実現します。

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
    <ds:Reference URI="#_d71a3a8e9ee6e4fd0b3b1f9c0e8e5c7b">
      <ds:Transforms>
        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
      </ds:Transforms>
      <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
      <ds:DigestValue>jFDPb/...=</ds:DigestValue>
    </ds:Reference>
  </ds:SignedInfo>

  <ds:SignatureValue>
    5Xda3xD3M7EzM9pL2Q4R9S8T1U2V3W4X5Y6Z7A8B9C0D1E2F3G4H5I6J7K8L9M0N1O2P3Q4R5S6T7U8=
  </ds:SignatureValue>

  <ds:KeyInfo>
    <ds:X509Data>
      <ds:X509Certificate>
        MIIDXTCCAkWgAwIBAgIJAKHHCgVDRV2dMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNVBAYTAlB...
      </ds:X509Certificate>
    </ds:X509Data>
  </ds:KeyInfo>
</ds:Signature>

署名検証フロー(SPでの処理):

  1. AssertionのIssuerを確認
  2. IdPのメタデータからIdPの公開鍵を取得
  3. SignatureValueを公開鍵で検証
  4. DigestValueがAssertion内容と一致することを確認
  5. 署名が有効な場合のみ、Assertionを受け入れ

XML暗号化

機密属性情報(パスワード、マイナンバーなど)が含まれる場合、XML暗号化によってAssertionを保護します。

<saml:Assertion>
  <!-- 平文の要素 -->
  <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
    Type="http://www.w3.org/2001/04/xmlenc#Element">
    <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
    <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
      <xenc:EncryptedKey>
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
        <ds:KeyInfo>
          <ds:X509Data>
            <ds:X509Certificate>
              <!-- SP公開鍵 -->
            </ds:X509Certificate>
          </ds:X509Data>
        </ds:KeyInfo>
        <xenc:CipherData>
          <!-- 暗号化されたセッション鍵 -->
        </xenc:CipherData>
      </xenc:EncryptedKey>
    </ds:KeyInfo>
    <xenc:CipherData>
      <!-- 暗号化されたAttribute -->
    </xenc:CipherData>
  </xenc:EncryptedData>
</saml:Assertion>

Profile:使用パターン定義

Web Browser SSO Profile

最も一般的なSAML利用シーン:ブラウザでログインが必要な場合

User Agent (Browser)
   ↓
1. ユーザーがSPのログインページにアクセス
   ↓
2. SPがAuthnRequestを生成、ブラウザを経由してIdPへ送信
   ↓
3. ユーザーがIdPで認証(パスワード、MFA等)
   ↓
4. IdPがSAML ResponseをACSにPOST
   ↓
5. ブラウザがFormをAutoSubmit
   ↓
6. SPがResponseを検証、セッション発行
   ↓
7. ユーザーが保護されたリソースにアクセス可能

Enhanced Client or Proxy Profile

OutlookなどのリッチクライアントでのSSO実装

メタデータ交換

IdPメタデータ

IdPが公開する、SPが信頼するための情報源

<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
  entityID="https://idp.example.com">

  <IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">

    <KeyDescriptor use="signing">
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <X509Data>
          <X509Certificate>
            MIIDXTCCAkWgAwIBAgIJAKHHCgVDRV2dMA0GCSqGSIb3...
          </X509Certificate>
        </X509Data>
      </KeyInfo>
    </KeyDescriptor>

    <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
      Location="https://idp.example.com/sso"/>

    <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
      Location="https://idp.example.com/sso"/>

    <NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>

  </IDPSSODescriptor>
</EntityDescriptor>

SPメタデータ

SPが公開する、IdPが信頼するための情報源

<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
  entityID="https://sp.example.com">

  <SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">

    <KeyDescriptor use="encryption">
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <X509Data>
          <X509Certificate>
            MIIDXTCCAkWgAwIBAgIJAKHHCgVDRV2dMA0GCSqGSIb3...
          </X509Certificate>
        </X509Data>
      </KeyInfo>
    </KeyDescriptor>

    <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
      Location="https://sp.example.com/acs" isDefault="true" index="0"/>

    <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
      Location="https://sp.example.com/acs-redirect" index="1"/>

  </SPSSODescriptor>
</EntityDescriptor>

LOCKED MSO でのSAML 2.0実装

LOCKED MSO は、OASIS SAML 2.0仕様に完全準拠した実装を提供します。

管理画面での設定例

【SAML認証設定】
- Protocol Version: SAML 2.0
- NameID Format: email(自動選択可)
- Binding: HTTP-POST(推奨)
- Encryption: AES-256
- 署名アルゴリズム: SHA-256

【属性マッピング**:
IdP属性 → LOCKED MSO内部属性
- mail → Email
- givenName → FirstName
- sn → LastName
- department → Department

【セッション設定】:
- Assertion有効期限: 300秒(デフォルト)
- セッション有効期限: 8時間
- セッションタイムアウト: 30分

実装上の注意点

証明書の更新管理

SAML署名用証明書は通常1~3年の有効期限を持ちます。更新漏れは致命的なインシデントになります。

LOCKED MSO の自動管理機能

  • 証明書有効期限30日前にアラート
  • 新証明書への段階的切り替え
  • 新旧両証明書で署名検証(トランジション期間)

時刻同期(ClockSkew)

Assertionの有効性判定では、IssuInstant と NotOnOrAfter の時刻を検証します。サーバーとIdPの時刻ズレは認証失敗につながります。

推奨設定:ClockSkewTolerance = 60秒(デフォルト30秒)

大規模導入事例

大手製造業(従業員 8,000名)では、グローバルサイトのActive Directory に加え、SAML SSO を統合しました。

成果

  • パスワードリセット要求:月間50件削減
  • ログイン失敗トラブル:80%削減
  • 監査対応の自動化で、コンプライアンス対応コスト 50%削減

まとめ

SAML 2.0は複雑に見えますが、Assertion → Protocol → Binding という3段階で理解すれば、実装と運用は段階的に習得できます。LOCKED MSO なら、這の複雑さを隠蔽し、シンプルな管理画面で SAML SSO を実現できます。


参考資料・外部リンク

関連記事

LOCKEDの詳細を見る

シングルサインオン・認証管理でお悩みなら、LOCKEDの無料デモをお試しください。

資料請求・デモ依頼はこちら →

商標について:本記事に記載されているOktaOneLoginAzure AD等の製品名・サービス名は、各社の商標または登録商標です。

免責事項:本記事の情報は執筆時点のものであり、各製品の最新の機能・料金・仕様については、各社の公式サイトをご確認ください。本記事の内容に基づく判断・行動について、当社は一切の責任を負いかねます。

LOCKED MSO

この課題、LOCKEDで解決できます

「IDaaS導入RFPテンプレート」など、検討に役立つ資料を無料でご用意しています

LOCKEDシリーズの詳細資料を無料でダウンロード

導入事例、機能詳細、他社比較など、検討に必要な情報をまとめた資料をご用意しています

まずは資料で詳細を確認

製品資料で機能・料金・導入事例をまとめてご確認いただけます

資料をダウンロード