Skip to content

Commit cad1232

Browse files
committed
CCM-10422: update dl auth
1 parent 849108f commit cad1232

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed

infrastructure/terraform/modules/backend-api/module_lambda_request_proof.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ data "aws_iam_policy_document" "request_proof_lambda_policy" {
4747
aws_dynamodb_table.templates.arn,
4848
]
4949
}
50-
5150
statement {
5251
sid = "AllowProofingSQS"
5352
effect = "Allow"

utils/utils/src/__tests__/lambda-cognito-authorizer.test.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,35 +136,6 @@ describe('LambdaCognitoAuthorizer', () => {
136136
expect(mockLogger.logMessages).toEqual([]);
137137
});
138138

139-
test('returns success on valid token when expected resource owner is the user (not client)', async () => {
140-
const jwt = sign(
141-
{
142-
token_use: 'access',
143-
client_id: 'user-pool-client-id',
144-
iss: 'https://cognito-idp.eu-west-2.amazonaws.com/user-pool-id',
145-
'nhs-notify:client-id': 'nhs-notify-client-id',
146-
},
147-
'key',
148-
{
149-
keyid: 'key-id',
150-
}
151-
);
152-
153-
const res = await authorizer.authorize(
154-
userPoolId,
155-
userPoolClientId,
156-
jwt,
157-
'sub'
158-
);
159-
160-
expect(res).toEqual({
161-
success: true,
162-
subject: 'sub',
163-
clientId: 'nhs-notify-client-id',
164-
});
165-
expect(mockLogger.logMessages).toEqual([]);
166-
});
167-
168139
test('returns failure on malformed token', async () => {
169140
const res = await authorizer.authorize(
170141
userPoolId,
@@ -401,7 +372,7 @@ describe('LambdaCognitoAuthorizer', () => {
401372
);
402373
});
403374

404-
test('returns failure when expected resourc owner matches neither notify client id nor sub, from Cognito', async () => {
375+
test('returns failure when expected resource owner does not match notify client id from Cognito', async () => {
405376
const jwt = sign(
406377
{
407378
token_use: 'access',

utils/utils/src/lambda-cognito-authorizer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,9 @@ export class LambdaCognitoAuthorizer {
9292

9393
if (
9494
expectedResourceOwner !== undefined &&
95-
expectedResourceOwner !== sub &&
9695
expectedResourceOwner !== notifyClientId
9796
) {
98-
this.logger.warn(
99-
'Neither subject nor clientId matches expected resource owner'
100-
);
97+
this.logger.warn('clientId does not match expected resource owner');
10198
return { success: false };
10299
}
103100

0 commit comments

Comments
 (0)