question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(apigatewayv2): Allow to set Lambda authorizer for WebSocket API

See original GitHub issue

Please allow us to set a Lambda authorizer for a WebSocket API. Currently we cannot set it because there’s no interface for it.

Use Case

Restrict access to a WebSocket API by cognito auth or other auth method.

Proposed Solution

Setting an authorizer for a WebSocket API is simple. You must only set authorizationType and authorizerId when creating a CfnRoute to $connect https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-route.html

Because you can only set authorizer for $connect route.

And there’s only one authorizer type; LambdaAuthorizer.

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:15
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tmokmsscommented, Dec 21, 2022

@wakeupmh Hi, here’s an example for that. https://github.com/aws-samples/websocket-api-cognito-auth-sample/tree/main/cdk

You have to create a Lambda function to verify JWTs (implementation is very simple thanks to aws-jwt-veryfy lib), and use the function as a Lambda authorizer.

1reaction
tmokmsscommented, Apr 14, 2021

Also there is a sample for adding Lambda authorizer to a WebSocket API written in TypeScript. https://github.com/aws-samples/websocket-api-cognito-auth-sample/blob/main/cdk/lib/construct/websocket.ts

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS::ApiGatewayV2::Authorizer - AWS CloudFormation
The AWS::ApiGatewayV2::Authorizer resource creates an authorizer for a WebSocket API or an HTTP API. To learn more, see Controlling and managing access to...
Read more >
Working with Amazon Lambda authorizers for HTTP APIs
You can enable caching for a Lambda authorizer by specifying an authorizerResultTtlInSeconds. When caching is enabled for an authorizer, API Gateway uses the ......
Read more >
Cannot Create Lambda Authorizer Using API Gateway ...
I cannot add a lambda authorizer to my WebSocket API from the AWS Console. When I click the `Create` button, I get a...
Read more >
REST API (API Gateway v1)
HTTP Endpoints with Custom Authorizers. Custom Authorizers allow you to run an AWS Lambda Function before your targeted AWS Lambda Function. This is...
Read more >
aws_apigatewayv2_authorizer | Resources | hashicorp/aws
Manages an Amazon API Gateway Version 2 authorizer. ... Basic WebSocket API ... Supported only for HTTP API Lambda authorizers. authorizer_uri - (Optional) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found