AWS CognitoとLambdaを連携する

AWS CognitoとLambdaを連携する

AWS Cognitoでは、以下のタイミングでLambda関数を呼び出すことができます。

  • サインアップ前
  • 認証前
  • カスタムメッセージ
  • 認証後
  • 確認後
  • 認証チャレンジの定義
  • 認証チャレンジの作成
  • 認証チャレンジレスポンスの確認
  • ユーザーの移行
  • トークン生成前

サインイン後にLambdaを呼び出すにはマネジメントコンソールよりLambda関数を指定しておきます。

AWS CognitoとLambdaを連携する

eventオブジェクトを出力した例です。

{
  "version": "1",
  "region": "us-east-2",
  "userPoolId": "us-east-2_xxx",
  "userName": "user01", // CognitoのユーザIDです
  "callerContext": {
    "awsSdkVersion": "aws-sdk-js-2.6.4",
    "clientId": "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
  },
  "triggerSource": "PostAuthentication_Authentication",
  "request": {
    "userAttributes": {
      "sub": "xxxxxxxxxxxxxxxxxxxxx",
      "email_verified": "false",
      "cognito:user_status": "CONFIRMED",
      "email": "example@example.com"
    },
    "newDeviceUsed": false
  },
"response": {}
}

ユーザープールのワークフローのカスタマイズ

コメント

タイトルとURLをコピーしました