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);
};
gefragt vor 5 Jahren1275 Aufrufe
1 Antwort
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>"

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen