Deny request in Cognito Pre Authentication lambda using dot net core

0

What's the equivalent of C# for node.js code below?

I'm trying to convert this node.js code back to dot net core. I would like to know new Error equivalent in C#.

Reference:
https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-authentication.html#aws-lambda-triggers-pre-authentication-example

exports.handler = (event, context, callback) => {
    if (event.callerContext.clientId === "user-pool-app-client-id-to-be-blocked") {
        var error = new Error("Cannot authenticate users from this user pool app client");

        // Return error to Amazon Cognito
        callback(error, event);
    }

    // Return to Amazon Cognito
    callback(null, event);
};
질문됨 5년 전1274회 조회
1개 답변
0

I figured it out myself. Throw and exception is indeed the approach.

However, there's not much flexible in return message. It's a canned message with prefix.

"PreAuthentication failed with error <your exception message here>"

답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠