Knowledge Center Monthly Newsletter - September 2025
Stay up to date with the latest from the Knowledge Center. See all new Knowledge Center articles published in the last month, and re:Post’s top contributors.
Amazon Cognito と外部 SAML ID プロバイダーの統合と構成を安全に実施する方法を教えてください。
Amazon Cognito ユーザープールにおいて、外部 SAML ID プロバイダー (IdP) の暗号化 SAML アサーションを使用する設定を行いたいと考えています。この方法で、アプリケーションのユーザー認証を安全に行えるようにしたいです。
解決策
SAML IdP をユーザープールに追加する
Amazon Cognito ユーザープールがない場合は、「ユーザープールの開始方法」を参照してください。ユーザープールの作成後、IdP 側で SAML アプリケーションを構成します。Amazon Cognito ユーザープールに SAML IdP を追加する方法については、「ユーザープールに SAML ID プロバイダーを追加し、管理する」を参照してください。
暗号化 SAML アサーションを Amazon Cognito に送信するために、暗号化証明書を SAML IdP に提供する
まず、Amazon Cognito コンソールで暗号化証明書をダウンロードします。次に、SAML IdP の構成インターフェイスで暗号化証明書をインポートします。暗号化証明書をインポートして有効化する方法については、使用する IdP のマニュアルを参照してください。たとえば、Microsoft Learn のウェブサイトでは、「Microsoft Entra の SAML トークン暗号化を構成する」を参照します。
暗号化 SAML アサーションフローを確認する
次の手順を実行します。
- ブラウザの開発者ツールを開き、HTTP Archive (HAR) ファイルを作成します。
- Amazon Cognito ユーザープールのマネージドログインページに移動します。
- [SAML IdP] を選択します。Amazon Cognito は、ユーザーを IdP のサインインページにリダイレクトします。
- IdP が saml2/idpresponse エンドポイントに送信した SAML アサーションリクエストを HAR ファイルから取得します。
- HAR ファイルの SAML アサーション応答をブラウザで表示します。
暗号化された SAML アサーションを含む、デコードされた SAML 応答の例:
<saml:EncryptedAssertion> <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"/> <xenc:CipherData> <xenc:CipherValue> <!-- Encrypted key data --> hY7PK8L9eM+2Uw7....[abbreviated]....4nmB2gTfLwqX= </xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedKey> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue> <!-- Encrypted assertion data --> kB4urcHh7K5HHJ....[abbreviated]....8JpWGpfTj= </xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </saml:EncryptedAssertion>
デコードされた非暗号化 SAML 応答の例:
<saml:Assertion ID="ASRT#########" Version="2.0" IssueInstant="2024-07-10T10:00:00Z"> <saml:Issuer>https://idp.example.com/saml</saml:Issuer> <saml:Subject> <saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"> USER123456789 </saml:NameID> <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> <saml:SubjectConfirmationData NotOnOrAfter="2024-07-10T11:00:00Z" Recipient="https://app.example.com/saml/acs"/> </saml:SubjectConfirmation> </saml:Subject> <saml:Conditions NotBefore="2024-07-10T10:00:00Z" NotOnOrAfter="2024-07-10T11:00:00Z"> <saml:AudienceRestriction> <saml:Audience>https://app.example.com/saml</saml:Audience> </saml:AudienceRestriction> </saml:Conditions> <saml:AuthnStatement AuthnInstant="2024-07-10T10:00:00Z" SessionNotOnOrAfter="2024-07-10T18:00:00Z" SessionIndex="SESSION123456789"> <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="uid" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"> <saml:AttributeValue>user123</saml:AttributeValue> </saml:Attribute> <saml:Attribute Name="email" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"> <saml:AttributeValue>user@example.com</saml:AttributeValue> </saml:Attribute> <saml:Attribute Name="roles" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic"> <saml:AttributeValue>user</saml:AttributeValue> <saml:AttributeValue>admin</saml:AttributeValue> </saml:Attribute> </saml:AttributeStatement> </saml:Assertion>
注: 応答の saml:EncryptedAssertion は、暗号化 SAML アサーションが存在することを示します。使用する IdP のみが、適切なプライベートキーを利用するとコンテンツを復号し、読み取ることができます。saml:EncryptedAssertion が応答に含まれていない場合は、SAML アサーションは暗号化されておらず、ユーザーと認証の詳細はクリアテキストで表示されます。
関連情報
- 言語
- 日本語
