Skip to content

Commit 74eee1e

Browse files
authored
fix(apigatewayv2-authorizers): incorrect identitySource default for 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*
1 parent 5ddaef4 commit 74eee1e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@aws-cdk/aws-apigatewayv2-authorizers/lib/websocket/lambda.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ export interface WebSocketLambdaAuthorizerProps {
2828
/**
2929
* The identity source for which authorization is requested.
3030
*
31-
* @default ['$request.header.Authorization']
31+
* Request parameter match `'route.request.querystring|header.[a-zA-z0-9._-]+'`.
32+
* Staged variable match `'stageVariables.[a-zA-Z0-9._-]+'`.
33+
* Context parameter match `'context.[a-zA-Z0-9._-]+'`.
34+
*
35+
* @default ['route.request.header.Authorization']
3236
*/
3337
readonly identitySource?: string[];
3438
}
@@ -56,7 +60,7 @@ export class WebSocketLambdaAuthorizer implements IWebSocketRouteAuthorizer {
5660
this.authorizer = new WebSocketAuthorizer(options.scope, this.id, {
5761
webSocketApi: options.route.webSocketApi,
5862
identitySource: this.props.identitySource ?? [
59-
'$request.header.Authorization',
63+
'route.request.header.Authorization',
6064
],
6165
type: WebSocketAuthorizerType.LAMBDA,
6266
authorizerName: this.props.authorizerName ?? this.id,

packages/@aws-cdk/aws-apigatewayv2-authorizers/test/websocket/lambda.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('WebSocketLambdaAuthorizer', () => {
3535
Name: 'default-authorizer',
3636
AuthorizerType: 'REQUEST',
3737
IdentitySource: [
38-
'$request.header.Authorization',
38+
'route.request.header.Authorization',
3939
],
4040
});
4141

0 commit comments

Comments
 (0)