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);
};
asked 4 years ago1237 views
1 Answer
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>"

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions