Skip to content

Commit d883e3e

Browse files
Merge pull request #189 from NHSDigital/feature/CCM-7251_lambda-authoriser
CCM-7251: Implement lambda authoriser
2 parents cc97bcf + 3aebc6b commit d883e3e

File tree

17 files changed

+4080
-155
lines changed

17 files changed

+4080
-155
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@
8888
{
8989
"files": ["*.test.{ts,tsx}"],
9090
"rules": {
91-
"unicorn/no-useless-undefined": "off"
91+
"unicorn/no-useless-undefined": "off",
92+
"unicorn/consistent-function-scoping": "off"
9293
}
9394
}
9495
]

.github/workflows/stage-2-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
- name: "Repo setup"
5252
run: |
5353
npm ci
54+
(cd lambdas/authorizer && npm ci)
5455
- name: "Generate dependencies"
5556
run: |
5657
npm run generate-dependencies
@@ -80,6 +81,7 @@ jobs:
8081
run: |
8182
npm ci
8283
npm ci tests/test-team
84+
(cd lambdas/authorizer && npm ci)
8385
- name: "Generate dependencies"
8486
run: |
8587
npm run generate-dependencies
@@ -97,6 +99,7 @@ jobs:
9799
run: |
98100
npm ci
99101
npm ci tests/test-team
102+
(cd lambdas/authorizer && npm ci)
100103
- name: "Generate dependencies"
101104
run: |
102105
npm run generate-dependencies

.github/workflows/stage-4-acceptance.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
- name: "Repo setup"
9797
run: |
9898
npm ci
99+
(cd lambdas/authorizer && npm ci)
99100
- name: "Generate dependencies"
100101
run: |
101102
npm run generate-dependencies
@@ -128,6 +129,7 @@ jobs:
128129
run: |
129130
npm ci
130131
npm ci tests/test-team
132+
(cd lambdas/authorizer && npm ci)
131133
- name: "Generate dependencies"
132134
run: |
133135
npm run generate-dependencies

infrastructure/terraform/components/app/module_templates_api.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ module "templates_api" {
88
group = var.group
99
csi = local.csi
1010
log_retention_in_days = var.log_retention_in_days
11+
12+
cognito_config = jsondecode(data.aws_ssm_parameter.cognito_config.value)
1113
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "aws_ssm_parameter" "cognito_config" {
2+
name = "/${local.csi}/cognito_config"
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "aws_api_gateway_method_settings" "main" {
2+
rest_api_id = aws_api_gateway_rest_api.main.id
3+
stage_name = aws_api_gateway_stage.main.stage_name
4+
method_path = "*/*"
5+
6+
settings {
7+
metrics_enabled = true
8+
logging_level = "INFO"
9+
data_trace_enabled = true
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_cloudwatch_log_group" "api_gateway_execution" {
2+
name = format("API-Gateway-Execution-Logs_%s/%s",
3+
aws_api_gateway_rest_api.main.id,
4+
var.environment,
5+
)
6+
retention_in_days = var.log_retention_in_days
7+
}

infrastructure/terraform/modules/templates-api/module_authorizer_lambda.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module "authorizer_lambda" {
99
handler = "index.handler"
1010

1111
log_retention_in_days = var.log_retention_in_days
12+
13+
environment_variables = var.cognito_config
1214
}
1315

1416
module "authorizer_build" {

infrastructure/terraform/modules/templates-api/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ variable "log_retention_in_days" {
5252
description = "The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite"
5353
default = 0
5454
}
55+
56+
variable "cognito_config" {
57+
type = object({
58+
USER_POOL_ID: string,
59+
USER_POOL_CLIENT_ID: string
60+
})
61+
description = "Cognito config"
62+
}

jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const config: Config = {
7878
'fixture',
7979
'helpers.ts',
8080
'/tests/test-team/',
81-
'.build'
81+
'.build',
8282
],
8383

8484
// Set the absolute path for imports

0 commit comments

Comments
 (0)