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 Answer
0
Accepted Answer
profile pictureAWS
EXPERT
answered 2 years ago
profile pictureAWS
EXPERT
reviewed 2 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