Cognitoユーザープールにメール認証によるMFAを導入 #1401
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Please explain the changes in detail.
If there is any impact on existing users (compatibility, degradation, breaking changes, etc.), be sure to include it in the explanation.
CognitoユーザープールへMFA有効化を追加し、ログイン時にメールを用いたMFAを可能としました。
変更内容
cdk.jsonに以下の設定パラメータを追加しましたmfaEnabled: MFA機能の有効/無効を制御(デフォルト: false)mfaFromEmail: MFA認証コード送信元メールアドレス(例:no-reply@example.com)mfaReplyToEmail: 返信先メールアドレス(オプション)デプロイ済み環境への影響
mfaEnabledのデフォルト値はfalseのため、デプロイ済み環境への影響はありませんcdk.jsonでmfaEnabled: true,mfaFromEmailに送信元メールアドレスをに設定し、SESの事前設定を完了させてからCDKスタックの更新が必要です注意事項
MFA有効化時はパスワードリセットが制限されます
AWS公式ドキュメントに記載の通り、CognitoユーザープールではMFAとパスワードリセットコードを同じメールアドレス(または電話番号)で受け取ることができません
メールベースのMFAを有効化した場合、セルフサービスでパスワードリセットを行うにはSMS(電話番号)が必要ですが、電話番号を必須属性として追加することは既存のCognitoユーザープールへの破壊的変更となるため、本PRでは以下の対応としました
補足事項
SESドメイン認証
mfaFromEmailで指定するメールアドレスのドメインは、Amazon SESで認証済みである必要がありますcdk.jsonにて任意の値を設定可能ですAmazon SESの独自ドメイン認証設定スクリプト(注意: Route 53のDNS設定を書き換えます)
メールのカスタマイズの制限
Checklist
npm run cdk:testand if there are snapshot differences, executenpm run cdk:test:update-snapshotto update snapshotsRelated Issues
Please list related issues as much as possible.