我正在定义有关用户身份验证的自定义挑战。我创建了一些lambda:
"use strict";
exports.handler = (event, context, callback) => {
// throw new Error("tutoring-define-auth-challenge");
if (event.request.session.length == 1 && event.request.session[0].challengeName == 'SRP_A') {
event.response.issueTokens = false;
event.response.failAuthentication = false;
event.response.challengeName = 'PASSWORD_VERIFIER';
} else if (event.request.session.length == 2 && event.request.session[1].challengeName == 'PASSWORD_VERIFIER' && event.request.session[1].challengeResult == true) {
event.response.issueTokens = false;
event.response.failAuthentication = false;
event.response.challengeName = 'CUSTOM_CHALLENGE';
} else if (event.request.session.length == 3 && event.request.session[2].challengeName == 'CUSTOM_CHALLENGE' && event.request.session[2].challengeResult == true) {
event.response.issueTokens = true;
event.response.failAuthentication = false;
} else {
event.response.issueTokens = false;
event.response.failAuthentication = true;
}
// Return to Amazon Cognito
callback(null, event);
}
"use strict";
const publicKey = require('./public');
exports.handler = async (event) => {
//throw new Error("tutoring-create-auth-challenge");
event.response.privateChallengeParameters = { key: publicKey.key };
return event;
};
问题在于这些lambda没有被触发。我在每个错误中都添加了错误(请参见注释掉的代码),但是我可以注册并登录而没有任何问题。
我想做的是通过检查自定义JWT令牌(而不是通过电子邮件发送的验证码)来添加新的挑战。
要使其正常工作,我还需要做什么?我检查了cloudwatch,可能只能从手动lambda的执行中找到日志。
答案 0 :(得分:0)