Skip to content

Commit ce5d0d7

Browse files
committed
whitespace fix
1 parent 8dddd7c commit ce5d0d7

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

infrastructure/terraform/components/app/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
|------|--------|---------|
5252
| <a name="module_amplify_branch"></a> [amplify\_branch](#module\_amplify\_branch) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/amp_branch | v1.0.0 |
5353
| <a name="module_backend_api"></a> [backend\_api](#module\_backend\_api) | ../../modules/backend-api | n/a |
54+
| <a name="module_download_authorizer_lambda"></a> [download\_authorizer\_lambda](#module\_download\_authorizer\_lambda) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/lambda | v2.0.2 |
5455
| <a name="module_eventpub"></a> [eventpub](#module\_eventpub) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/eventpub | v1.0.13 |
5556
| <a name="module_kms"></a> [kms](#module\_kms) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/kms | v1.0.8 |
5657
| <a name="module_nhse_backup_vault"></a> [nhse\_backup\_vault](#module\_nhse\_backup\_vault) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/aws-backup-source | v1.0.8 |

infrastructure/terraform/components/app/cloudfront_distribution_cdn.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ resource "aws_cloudfront_distribution" "main" {
2929
domain_name = module.backend_api.download_bucket_regional_domain_name
3030
origin_access_control_id = aws_cloudfront_origin_access_control.main.id
3131
origin_id = "S3-${local.csi}-download"
32-
32+
3333
custom_header {
3434
name = "x-user-pool-id"
3535
value = jsondecode(aws_ssm_parameter.cognito_config.value)["USER_POOL_ID"]

lambdas/download-authorizer/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929
"zod": "^3.24.2"
3030
}
3131
}
32-
s

lambdas/download-authorizer/src/index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import type { CloudFrontHeaders, CloudFrontRequestEvent } from "aws-lambda";
2-
import { z } from "zod";
1+
import type { CloudFrontHeaders, CloudFrontRequestEvent } from 'aws-lambda';
2+
import { z } from 'zod';
33
import {
44
CognitoIdentityProviderClient,
55
GetUserCommand,
6-
} from "@aws-sdk/client-cognito-identity-provider";
7-
import { jwtDecode } from "jwt-decode";
8-
import { verify } from "jsonwebtoken";
9-
import getJwksClient from "jwks-rsa";
6+
} from '@aws-sdk/client-cognito-identity-provider';
7+
import { jwtDecode } from 'jwt-decode';
8+
import { verify } from 'jsonwebtoken';
9+
import getJwksClient from 'jwks-rsa';
1010

1111
const cognitoClient = new CognitoIdentityProviderClient({
12-
region: "eu-west-2",
12+
region: 'eu-west-2',
1313
});
1414

1515
const $AccessToken = z.object({
@@ -19,16 +19,16 @@ const $AccessToken = z.object({
1919
});
2020

2121
const deny = {
22-
status: "403",
23-
statusDescription: "Forbidden",
24-
body: "<h1>Access Denied</h1>",
22+
status: '403',
23+
statusDescription: 'Forbidden',
24+
body: '<h1>Access Denied</h1>',
2525
};
2626

2727
function authFromCookie(headers: CloudFrontHeaders) {
2828
const cookie = headers.cookie?.[0]?.value;
29-
const parts = (cookie ?? "").split("; ");
30-
const kvParts = parts.map((p) => p.split("="));
31-
const [, t] = kvParts.find(([k]) => k.endsWith("accessToken")) ?? [];
29+
const parts = (cookie ?? '').split('; ');
30+
const kvParts = parts.map((p) => p.split('='));
31+
const [, t] = kvParts.find(([k]) => k.endsWith('accessToken')) ?? [];
3232
return t;
3333
}
3434

@@ -41,15 +41,15 @@ export const handler = async (event: CloudFrontRequestEvent) => {
4141

4242
const authorizationToken = authFromCookie(request.headers);
4343
const userPoolId =
44-
request.origin?.s3?.customHeaders["x-user-pool-id"]?.[0].value;
44+
request.origin?.s3?.customHeaders['x-user-pool-id']?.[0].value;
4545
const userPoolClientId =
46-
request.origin?.s3?.customHeaders["x-user-pool-client-id"]?.[0].value;
46+
request.origin?.s3?.customHeaders['x-user-pool-client-id']?.[0].value;
4747

4848
console.log(userPoolId, userPoolClientId);
4949

5050
try {
5151
if (!authorizationToken) {
52-
console.warn("no token");
52+
console.warn('no token');
5353
return deny;
5454
}
5555

@@ -64,7 +64,7 @@ export const handler = async (event: CloudFrontRequestEvent) => {
6464
const { kid } = decodedToken;
6565

6666
if (!kid) {
67-
console.warn("Authorization token missing kid");
67+
console.warn('Authorization token missing kid');
6868
return deny;
6969
}
7070

@@ -86,7 +86,7 @@ export const handler = async (event: CloudFrontRequestEvent) => {
8686
}
8787

8888
// token_use claim
89-
if (tokenUse !== "access") {
89+
if (tokenUse !== 'access') {
9090
console.warn(
9191
`Token has invalid token_use, expected access but received ${tokenUse}`
9292
);
@@ -101,19 +101,19 @@ export const handler = async (event: CloudFrontRequestEvent) => {
101101
);
102102

103103
if (!Username || !UserAttributes) {
104-
console.warn("Missing user");
104+
console.warn('Missing user');
105105
return deny;
106106
}
107107

108-
const sub = UserAttributes.find(({ Name }) => Name === "sub")?.Value;
108+
const sub = UserAttributes.find(({ Name }) => Name === 'sub')?.Value;
109109

110110
if (!sub) {
111-
console.warn("Missing user subject");
111+
console.warn('Missing user subject');
112112
return deny;
113113
}
114114

115115
if (ownerPath !== sub) {
116-
console.warn("owner !== sub");
116+
console.warn('owner !== sub');
117117
return deny;
118118
}
119119

@@ -122,4 +122,4 @@ export const handler = async (event: CloudFrontRequestEvent) => {
122122
console.error(error);
123123
return deny;
124124
}
125-
};
125+
};

0 commit comments

Comments
 (0)