Skip to content

Commit

Permalink
Validate country code header (#242)
Browse files Browse the repository at this point in the history
* Validate country code header

* method

* recurrign
  • Loading branch information
tomrf1 authored Dec 17, 2024
1 parent 4d99162 commit 3ef53dd
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 7 deletions.
72 changes: 68 additions & 4 deletions cdk/lib/__snapshots__/support-reminders.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions cdk/lib/support-reminders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {GuVpc} from "@guardian/cdk/lib/constructs/ec2";
import {GuLambdaFunction} from "@guardian/cdk/lib/constructs/lambda";
import type {App} from "aws-cdk-lib";
import {Duration} from "aws-cdk-lib";
import { AwsIntegration, CfnBasePathMapping, CfnDomainName, Cors } from "aws-cdk-lib/aws-apigateway";
import {AwsIntegration, CfnBasePathMapping, CfnDomainName, Cors, RequestValidator} from "aws-cdk-lib/aws-apigateway";
import {ComparisonOperator, Metric} from "aws-cdk-lib/aws-cloudwatch";
import {SecurityGroup} from "aws-cdk-lib/aws-ec2";
import {Schedule} from "aws-cdk-lib/aws-events";
Expand Down Expand Up @@ -174,14 +174,28 @@ export class SupportReminders extends GuStack {
{
statusCode: '200',
},
]
],
requestParameters: {
'method.request.header.X-GU-GeoIP-Country-Code': true,
},
requestValidator: new RequestValidator(this, 'one-off-validator', {
restApi: supportRemindersApi.api,
validateRequestParameters: true
}),
});
supportRemindersApi.api.root.resourceForPath('/create/recurring').addMethod('POST', sendMessageIntegration, {
methodResponses: [
{
statusCode: '200',
},
]
],
requestParameters: {
'method.request.header.X-GU-GeoIP-Country-Code': true,
},
requestValidator: new RequestValidator(this, 'recurring-validator', {
restApi: supportRemindersApi.api,
validateRequestParameters: true
}),
});


Expand Down

0 comments on commit 3ef53dd

Please sign in to comment.