-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apigatewayv2): websocket api: api keys (#16636)
---- This PR adds support for requiring an API Key on Websocket API routes. Specifically, it does the following: * Exposes `apiKeyRequired` on route object (defaults to false) * Exposes `apiKeySelectionExpression` on api object In addition, the following has been added: * Logic to ensure `apiKeySelectionExpression` falls within the two currently supported values * Created a few basic integration tests for the api and route objects for websockets *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
beb5706
commit 24f8f74
Showing
7 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/@aws-cdk/aws-apigatewayv2/test/websocket/integ.api-apikey.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Resources": { | ||
"MyWebsocketApiEBAC53DF": { | ||
"Type": "AWS::ApiGatewayV2::Api", | ||
"Properties": { | ||
"ApiKeySelectionExpression": "$request.header.x-api-key", | ||
"Name": "MyWebsocketApi", | ||
"ProtocolType": "WEBSOCKET", | ||
"RouteSelectionExpression": "$request.body.action" | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/@aws-cdk/aws-apigatewayv2/test/websocket/integ.api-apikey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as apigw from '../../lib'; | ||
import { WebSocketApiKeySelectionExpression } from '../../lib'; | ||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2-websockets'); | ||
|
||
new apigw.WebSocketApi(stack, 'MyWebsocketApi', { | ||
apiKeySelectionExpression: WebSocketApiKeySelectionExpression.HEADER_X_API_KEY, | ||
}); | ||
|
||
app.synth(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters