Websocket Api not working with authorzer lamda

0

I have been trying to fix this since days now but I've no clue what is happening

I have created a websocket api using cdk which works fine but when I add authorzer to connect route I get 500 error. The authorizer lambda completes execution normally but the connect route lambda is never invoked

import { WebSocketApi, WebSocketAuthorizer, WebSocketAuthorizerType, WebSocketStage } from '@aws-cdk/aws-apigatewayv2-alpha'; import { WebSocketLambdaAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers-alpha'; import { WebSocketLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha';

const authorizer = new WebSocketLambdaAuthorizer('blessed-messanger-authorizer', authorizerHandler , { identitySource: ['route.request.querystring.token'] } );

this.webSocketApi = new WebSocketApi(this, 'blessed-messenger-api', { apiName: 'blessed-messenger', connectRouteOptions: { integration: new WebSocketLambdaIntegration("ConnectIntegration", onConnectHandler), authorizer }, defaultRouteOptions: { integration: new WebSocketLambdaIntegration("DefaultIntegration", onMessageHandler) }, disconnectRouteOptions: { integration: new WebSocketLambdaIntegration("DisconnectIntegration", onDisconnectHandler) }, });

This is my authorzer function. I have tried everything that is commented out in if block

exports.handler = async (event, context, callback) => { var queryStringParameters = event.queryStringParameters; var token = queryStringParameters.token; if(token === "some_user"){ // return generateAllow("some_user", event.methodArn); // callback(null, generateAllow("some_user", event.methodArn); return { statusCode: 200, body: "OK" }; }else{ callback("Unauthorized"); } };

I have read these questions as well but no luck https://repost.aws/questions/QUfTsKsL47RYSz9z1OAZEYMA/websocket-authorizer-status-500

Please help

1 Antwort
0
Akzeptierte Antwort
profile pictureAWS
EXPERTE
beantwortet vor 2 Jahren
profile pictureAWS
EXPERTE
überprüft vor 2 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