Skip to content

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

Closed
@Hugodby

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2effort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.in-progressThis issue is being actively worked on.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions