From 87b6d1ed03e4dbe8bd9ad239d0bb36fb336fc335 Mon Sep 17 00:00:00 2001 From: Jasper <54336703+JazJax@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:32:10 +0000 Subject: [PATCH] Fixing deployment (#55) * reverted changes to helm. Still builds, but may still face problems with the audit logging * Allowing the SEARCH role to see the data * removing calls to AuditService temporarily, until Cloud Platform changes deployed --- .../values.yaml | 6 +-- helm_deploy/values-dev.yaml | 17 +++---- .../resource/OrderController.kt | 33 +++++++------ .../resource/SearchController.kt | 46 ++++++++++--------- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/helm_deploy/hmpps-electronic-monitoring-datastore-api/values.yaml b/helm_deploy/hmpps-electronic-monitoring-datastore-api/values.yaml index 091d037..bf3f52c 100644 --- a/helm_deploy/hmpps-electronic-monitoring-datastore-api/values.yaml +++ b/helm_deploy/hmpps-electronic-monitoring-datastore-api/values.yaml @@ -20,7 +20,7 @@ generic-service: SERVER_PORT: "8080" APPLICATIONINSIGHTS_CONNECTION_STRING: "InstrumentationKey=$(APPINSIGHTS_INSTRUMENTATIONKEY)" APPLICATIONINSIGHTS_CONFIGURATION_FILE: applicationinsights.json - HMPPS_SQS_USEWEBTOKEN: true + # HMPPS_SQS_USEWEBTOKEN: true # <== COMMENTED OUT to investigate failing build 20/12/2024 # Pre-existing kubernetes secrets to load as environment variables in the deployment. # namespace_secrets: @@ -30,8 +30,8 @@ generic-service: namespace_secrets: hmpps-electronic-monitoring-datastore-api: APPINSIGHTS_INSTRUMENTATIONKEY: "APPINSIGHTS_INSTRUMENTATIONKEY" - CLIENT_ID: "API_CLIENT_ID" - CLIENT_SECRET: "API_CLIENT_SECRET" + # CLIENT_ID: "API_CLIENT_ID" # <== COMMENTED OUT to investigate failing build 20/12/2024 + # CLIENT_SECRET: "API_CLIENT_SECRET" # <== COMMENTED OUT to investigate failing build 20/12/2024 allowlist: groups: diff --git a/helm_deploy/values-dev.yaml b/helm_deploy/values-dev.yaml index c6e26e5..417142b 100644 --- a/helm_deploy/values-dev.yaml +++ b/helm_deploy/values-dev.yaml @@ -10,17 +10,18 @@ generic-service: host: electronic-monitoring-datastore-api-dev.hmpps.service.justice.gov.uk env: - SENTRY_ENV: dev + # SENTRY_ENV: dev # <== COMMENTED OUT to investigate failing build 20/12/2024 APPLICATIONINSIGHTS_CONFIGURATION_FILE: "applicationinsights.dev.json" HMPPS_AUTH_URL: "https://sign-in-dev.hmpps.service.justice.gov.uk/auth" - namespace_secrets: - hmpps-auth: - CLIENT_ID: "client-id" - CLIENT_SECRET: "client-secret" - other-services: - APPINSIGHTS_INSTRUMENTATIONKEY: "azure-app-insights" - SENTRY_DSN: "sentry" + # <== COMMENTED OUT to investigate failing build 20/12/2024 + # namespace_secrets: + # hmpps-auth: + # CLIENT_ID: "client-id" + # CLIENT_SECRET: "client-secret" + # other-services: + # APPINSIGHTS_INSTRUMENTATIONKEY: "azure-app-insights" + # SENTRY_DSN: "sentry" # CloudPlatform AlertManager receiver to route prometheus alerts to slack # See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/OrderController.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/OrderController.kt index ffeabed..5d78298 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/OrderController.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/OrderController.kt @@ -31,11 +31,12 @@ class OrderController( val repository = OrderInformationRepository() val orderInfo: OrderInformation = repository.getMockOrderInformation(orderId) - auditService.createEvent( - authentication.principal.toString(), - "GET_MOCK_ORDER_SUMMARY", - mapOf("orderId" to orderId), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "GET_MOCK_ORDER_SUMMARY", + // mapOf("orderId" to orderId), + // ) return ResponseEntity.ok(orderInfo) } @@ -51,11 +52,12 @@ class OrderController( return ResponseEntity.ok(repository.getMockOrderInformation(orderId)) - auditService.createEvent( - authentication.principal.toString(), - "GET_SPECIALS_ORDER_SUMMARY", - mapOf("orderId" to orderId), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "GET_SPECIALS_ORDER_SUMMARY", + // mapOf("orderId" to orderId), + // ) return ResponseEntity.ok( repository.getMockOrderInformation(orderId), @@ -85,11 +87,12 @@ class OrderController( documents = fakeOrder.documents, ) - auditService.createEvent( - authentication.principal.toString(), - "GET_ORDER_SUMMARY", - mapOf("orderId" to orderId), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "GET_ORDER_SUMMARY", + // mapOf("orderId" to orderId), + // ) return ResponseEntity.ok(result) } diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/SearchController.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/SearchController.kt index fffee36..a736d13 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/SearchController.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/electronicmonitoringdatastoreapi/resource/SearchController.kt @@ -23,7 +23,7 @@ import uk.gov.justice.digital.hmpps.electronicmonitoringdatastoreapi.service.Ath import uk.gov.justice.digital.hmpps.electronicmonitoringdatastoreapi.service.internal.AuditService @RestController -@PreAuthorize("hasAnyAuthority('ROLE_EM_DATASTORE_GENERAL_RO', 'ROLE_EM_DATASTORE_RESTRICTED_RO')") +@PreAuthorize("hasAnyAuthority('ROLE_EM_DATASTORE_GENERAL_RO', 'ROLE_EM_DATASTORE_RESTRICTED_RO', 'ROLE_ELECTRONIC_MONITORING_DATASTORE_API_SEARCH')") @RequestMapping(value = ["/search"], produces = [MediaType.APPLICATION_JSON_VALUE]) class SearchController( @Autowired val auditService: AuditService, @@ -66,11 +66,12 @@ class SearchController( val athenaService = AthenaService() val resultSet: ResultSet = athenaService.getQueryResult(validatedRole, queryString) - auditService.createEvent( - authentication.principal.toString(), - "SEARCH_TEST", - mapOf("queryString" to queryString), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "SEARCH_TEST", + // mapOf("queryString" to queryString), + // ) return ResponseEntity( resultSet, @@ -106,11 +107,12 @@ class SearchController( ) } - auditService.createEvent( - authentication.principal.toString(), - "SEARCH_WITH_CUSTOM_QUERY", - mapOf("queryString" to queryString), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "SEARCH_WITH_CUSTOM_QUERY", + // mapOf("queryString" to queryString), + // ) return AthenaQueryResponse( queryString = queryString, @@ -125,11 +127,12 @@ class SearchController( authentication: Authentication, @RequestBody orderSearchCriteria: OrderSearchCriteria, ): List { - auditService.createEvent( - authentication.principal.toString(), - "SEARCH_OLD_ORDERS", - mapOf("legacySubjectId" to orderSearchCriteria.legacySubjectId, "searchType" to orderSearchCriteria.searchType), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "SEARCH_OLD_ORDERS", + // mapOf("legacySubjectId" to orderSearchCriteria.legacySubjectId, "searchType" to orderSearchCriteria.searchType), + // ) return OrderRepository.Companion.getFakeOrders() } @@ -144,11 +147,12 @@ class SearchController( // 2: query repository val result: AthenaQueryResponse> = repository.getOrders(orderSearchCriteria) - auditService.createEvent( - authentication.principal.toString(), - "SEARCH_ORDERS", - mapOf("legacySubjectId" to orderSearchCriteria.legacySubjectId, "searchType" to orderSearchCriteria.searchType), - ) + // TODO: Re-enable audit once Cloud Platform in place + // auditService.createEvent( + // authentication.principal.toString(), + // "SEARCH_ORDERS", + // mapOf("legacySubjectId" to orderSearchCriteria.legacySubjectId, "searchType" to orderSearchCriteria.searchType), + // ) return ResponseEntity>( result.queryResponse,