Closed
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