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.

[@aws-cdk/aws-apigatewayv2] support authorizers for HTTP API

See original GitHub issue

I want to be able to add an authorizer when calling the addRoutes method. Similar to what is done in the apigateway construct: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.MethodOptions.html

Use Case

There are no straightforward to add an authorizer on HTTP API routes. This is an important security feature. Workaround are already available in blogposts: https://dev.to/martzcodes/token-authorizers-with-apigatewayv2-tricks-apigwv1-doesn-t-want-you-to-know-41jn

Proposed Solution

One solution would be to add an authorizer property on the addRoutes method:

const api = new HttpApi(this, 'Api', { .. });
const authorizer = new CfnAuthorizer(this, 'ApiAuthorizer', { ... });

api.addRoutes({
  path: '/route',
  methods: [ HttpMethod.GET ],
  integration: new LambdaProxyIntegration({ handler: Example }),
  authorizer: authorizer,
});
  • 👋 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 3 years ago
  • Reactions:45
  • Comments:38 (15 by maintainers)

github_iconTop GitHub Comments

27reactions
rtrivecommented, Nov 29, 2020

any updates on adding authorizer to http api route?

9reactions
iRoachiecommented, Feb 10, 2021

Hey all, we just merged https://github.com/aws/aws-cdk/pull/10972 which introduces support for JWT authorizers, and a convenience cognito user pool authorizer. Just the REQUEST authorizer needed to completely close this ticket

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws-cdk/aws-apigatewayv2-authorizers module
API Gateway supports multiple mechanisms for controlling and managing access to your HTTP API. They are mainly classified into Lambda Authorizers, ...
Read more >
@aws-cdk/aws-apigatewayv2-authorizers - npm
API Gateway supports multiple mechanisms for controlling and managing access to your HTTP API. They are mainly classified into Lambda ...
Read more >
@aws-cdk/aws-apigatewayv2-authorizers NPM | npm.io
API Gateway supports multiple mechanisms for controlling and managing access to your HTTP API. They are mainly classified into Lambda Authorizers, JWT ...
Read more >
AWS API with lambda Authorizer simple CDK code
Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket APIs at any scale.
Read more >
@aws-cdk/aws-apigatewayv2 - NPM Package Overview
Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket APIs at any ...
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