-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(apigatewayv2): Lambda authorizer for WebSocket API #16886
Conversation
This is perfect! Exactly what I need right now. I was planning to start a PR for myself. Any chance we can prioritize this? |
'$request.header.Authorization', | ||
], | ||
type: WebSocketAuthorizerType.LAMBDA, | ||
authorizerName: this.props.authorizerName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should fall back to the new id
constructor arg.
/** | ||
* The name of the authorizer | ||
*/ | ||
readonly authorizerName: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make this API consistent with HttpLambdaAuthorizer
/HttpLambdaAuthorizerProps
:
- Move
handler
to the constructor ofWebSocketLambdaAuthorizer
. - Pass an
id
to the constructor ofWebSocketLambdaAuthorizer
.
const id = this.props.authorizerName; | ||
|
||
this.webSocketApi = options.route.webSocketApi; | ||
this.authorizer = new WebSocketAuthorizer(options.scope, id, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you add the new id
constructor arg, replace id
with this.id
.
Pull request has been modified.
@otaviomacedo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
… `WebSocketLambdaAuthorizer` (#18315) We introduced `WebSocketLambdaAuthorizer` in #16886 with an incorrect default `identitySource`, according to these [docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource). The result is that using the default `identitySource` results in a deploy-time failure. This PR fixes the error and adds documentation for the syntax for all `identitySource` possibilities. I can confirm that this default successfully passes `cdk deploy` on my local app. Fixes #18307. BREAKING CHANGE: `WebSocketLambdaAuthorizerProps.identitySource` default changes from `['$request.header.Authorization']` to `['route.request.header.Authorization']`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
closes aws#13869 By this PR, you will be able to enable WebSocket authorizer as the below code: ```ts const integration = new LambdaWebSocketIntegration({ handler, }); const authorizer = new WebSocketLambdaAuthorizer('Authorizer', authHandler); new WebSocketApi(stack, 'WebSocketApi', { connectRouteOptions: { integration, authorizer, }, }); ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
… `WebSocketLambdaAuthorizer` (aws#18315) We introduced `WebSocketLambdaAuthorizer` in aws#16886 with an incorrect default `identitySource`, according to these [docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-authorizer.html#cfn-apigatewayv2-authorizer-identitysource). The result is that using the default `identitySource` results in a deploy-time failure. This PR fixes the error and adds documentation for the syntax for all `identitySource` possibilities. I can confirm that this default successfully passes `cdk deploy` on my local app. Fixes aws#18307. BREAKING CHANGE: `WebSocketLambdaAuthorizerProps.identitySource` default changes from `['$request.header.Authorization']` to `['route.request.header.Authorization']`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
closes #13869
By this PR, you will be able to enable WebSocket authorizer as the below code:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license