From 8b752799d12c24e26627dee903923f0e6daf4ea1 Mon Sep 17 00:00:00 2001 From: Riccardo Torsoli <122275960+nttdata-rtorsoli@users.noreply.github.com> Date: Tue, 31 Oct 2023 10:52:15 +0100 Subject: [PATCH] PIN-4138 Rid of IpAddress header (#190) Co-authored-by: nttdata-rtorsoli --- .../resources/interface-specification.yml | 23 ----- .../AuthorizationManagementServiceImpl.scala | 11 +-- .../impl/PurposeManagementServiceImpl.scala | 88 +++++++------------ 3 files changed, 38 insertions(+), 84 deletions(-) diff --git a/src/main/resources/interface-specification.yml b/src/main/resources/interface-specification.yml index 9dbac3c8..c54d027e 100644 --- a/src/main/resources/interface-specification.yml +++ b/src/main/resources/interface-specification.yml @@ -30,7 +30,6 @@ paths: /purposes: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' get: tags: - purpose @@ -152,11 +151,9 @@ paths: /reverse/purposes: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' post: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' tags: - purpose operationId: createPurposeFromEService @@ -195,7 +192,6 @@ paths: /reverse/purposes/{id}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: id in: path description: the purpose id @@ -206,7 +202,6 @@ paths: post: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' tags: - purpose operationId: updateReversePurpose @@ -233,7 +228,6 @@ paths: /purposes/{id}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: id in: path description: the purpose id @@ -268,7 +262,6 @@ paths: post: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' tags: - purpose operationId: updatePurpose @@ -295,7 +288,6 @@ paths: delete: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' tags: - purpose operationId: deletePurpose @@ -324,7 +316,6 @@ paths: /purposes/{purposeId}/versions: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path description: the purpose id @@ -359,7 +350,6 @@ paths: /purposes/{purposeId}/versions/{versionId}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -396,7 +386,6 @@ paths: /purposes/{purposeId}/versions/{versionId}/documents/{documentId}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' get: security: - bearerAuth: [] @@ -460,7 +449,6 @@ paths: /purposes/{purposeId}/versions/{versionId}/activate: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -501,7 +489,6 @@ paths: /purposes/{purposeId}/clone: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -542,7 +529,6 @@ paths: /purposes/{purposeId}/versions/{versionId}/suspend: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -583,7 +569,6 @@ paths: /purposes/{purposeId}/versions/{versionId}/archive: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -624,7 +609,6 @@ paths: /purposes/{purposeId}/versions/{versionId}/update/waitingForApproval: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: purposeId in: path required: true @@ -676,7 +660,6 @@ paths: /purposes/riskAnalysis/latest: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: tenantKind in: query schema: @@ -708,7 +691,6 @@ paths: /purposes/riskAnalysis/version/{riskAnalysisVersion}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' - - $ref: '#/components/parameters/IpAddress' - name: riskAnalysisVersion in: path required: true @@ -750,11 +732,6 @@ components: required: true schema: type: string - IpAddress: - in: header - name: X-Forwarded-For - schema: - type: string schemas: TenantKind: type: string diff --git a/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/AuthorizationManagementServiceImpl.scala b/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/AuthorizationManagementServiceImpl.scala index 0a5e57cb..1ae24961 100644 --- a/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/AuthorizationManagementServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/AuthorizationManagementServiceImpl.scala @@ -26,12 +26,11 @@ final case class AuthorizationManagementServiceImpl( override def updateStateOnClients(purposeId: UUID, versionId: UUID, state: ClientComponentState)(implicit contexts: Seq[(String, String)] ): Future[Unit] = - withHeaders { (bearerToken, correlationId, ip) => + withHeaders { (bearerToken, correlationId) => val request = purposeApi.updatePurposeState( xCorrelationId = correlationId, purposeId = purposeId, - clientPurposeDetailsUpdate = ClientPurposeDetailsUpdate(versionId = versionId, state = state), - xForwardedFor = ip + clientPurposeDetailsUpdate = ClientPurposeDetailsUpdate(versionId = versionId, state = state) )(BearerToken(bearerToken)) // Do not fail because this service should not be blocked by this update invoker @@ -41,11 +40,9 @@ final case class AuthorizationManagementServiceImpl( override def removePurposeFromClient(purposeId: UUID, clientId: UUID)(implicit contexts: Seq[(String, String)] - ): Future[Unit] = withHeaders { (bearerToken, correlationId, ip) => + ): Future[Unit] = withHeaders { (bearerToken, correlationId) => val request = - purposeApi.removeClientPurpose(xCorrelationId = correlationId, clientId, purposeId, xForwardedFor = ip)( - BearerToken(bearerToken) - ) + purposeApi.removeClientPurpose(xCorrelationId = correlationId, clientId, purposeId)(BearerToken(bearerToken)) invoker.invoke(request, s"Removing purpose $purposeId from client $clientId") } diff --git a/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/PurposeManagementServiceImpl.scala b/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/PurposeManagementServiceImpl.scala index 5a6e61df..b8af0c4d 100644 --- a/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/PurposeManagementServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/purposeprocess/service/impl/PurposeManagementServiceImpl.scala @@ -32,18 +32,16 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, Logger.takingImplicit[ContextFieldsToLog](this.getClass) override def createPurpose(seed: PurposeSeed)(implicit contexts: Seq[(String, String)]): Future[Purpose] = - withHeaders { (bearerToken, correlationId, ip) => + withHeaders { (bearerToken, correlationId) => val request = - api.createPurpose(xCorrelationId = correlationId, seed, xForwardedFor = ip)(BearerToken(bearerToken)) + api.createPurpose(xCorrelationId = correlationId, seed)(BearerToken(bearerToken)) invoker.invoke(request, s"Creating purpose for EService ${seed.eserviceId} and Consumer ${seed.consumerId}") } override def createPurposeVersion(purposeId: UUID, seed: PurposeVersionSeed)(implicit contexts: Seq[(String, String)] - ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId, ip) => - val request = api.createPurposeVersion(xCorrelationId = correlationId, purposeId, seed, xForwardedFor = ip)( - BearerToken(bearerToken) - ) + ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => + val request = api.createPurposeVersion(xCorrelationId = correlationId, purposeId, seed)(BearerToken(bearerToken)) invoker .invoke(request, s"Creating purpose version for Purpose $purposeId") .recoverWith { case err: ApiError[_] if err.code == 409 => Future.failed(PurposeVersionConflict(purposeId)) } @@ -51,11 +49,9 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, override def updatePurpose(purposeId: UUID, purposeUpdateContent: PurposeUpdateContent)(implicit contexts: Seq[(String, String)] - ): Future[Purpose] = withHeaders { (bearerToken, correlationId, ip) => + ): Future[Purpose] = withHeaders { (bearerToken, correlationId) => val request = - api.updatePurpose(xCorrelationId = correlationId, purposeId, purposeUpdateContent, xForwardedFor = ip)( - BearerToken(bearerToken) - ) + api.updatePurpose(xCorrelationId = correlationId, purposeId, purposeUpdateContent)(BearerToken(bearerToken)) invoker.invoke(request, s"Updating Purpose $purposeId") } @@ -124,9 +120,9 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, override def activatePurposeVersion(purposeId: UUID, versionId: UUID, payload: ActivatePurposeVersionPayload)(implicit contexts: Seq[(String, String)] - ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId, ip) => + ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => val request = - api.activatePurposeVersion(xCorrelationId = correlationId, purposeId, versionId, payload, xForwardedFor = ip)( + api.activatePurposeVersion(xCorrelationId = correlationId, purposeId, versionId, payload)( BearerToken(bearerToken) ) invoker.invoke( @@ -137,27 +133,20 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, override def suspendPurposeVersion(purposeId: UUID, versionId: UUID, stateChangeDetails: StateChangeDetails)(implicit contexts: Seq[(String, String)] - ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId, ip) => - val request = api.suspendPurposeVersion( - xCorrelationId = correlationId, - purposeId, - versionId, - stateChangeDetails, - xForwardedFor = ip - )(BearerToken(bearerToken)) + ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => + val request = api.suspendPurposeVersion(xCorrelationId = correlationId, purposeId, versionId, stateChangeDetails)( + BearerToken(bearerToken) + ) invoker.invoke(request, s"Suspending Version $versionId of Purpose $purposeId by ${stateChangeDetails.changedBy}") } override def waitForApprovalPurposeVersion(purposeId: UUID, versionId: UUID, stateChangeDetails: StateChangeDetails)( implicit contexts: Seq[(String, String)] - ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId, ip) => - val request = api.waitForApprovalPurposeVersion( - xCorrelationId = correlationId, - purposeId, - versionId, - stateChangeDetails, - xForwardedFor = ip - )(BearerToken(bearerToken)) + ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => + val request = + api.waitForApprovalPurposeVersion(xCorrelationId = correlationId, purposeId, versionId, stateChangeDetails)( + BearerToken(bearerToken) + ) invoker.invoke( request, s"Waiting for Approval for Version $versionId of Purpose $purposeId by ${stateChangeDetails.changedBy}" @@ -166,14 +155,10 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, override def archivePurposeVersion(purposeId: UUID, versionId: UUID, stateChangeDetails: StateChangeDetails)(implicit contexts: Seq[(String, String)] - ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId, ip) => - val request = api.archivePurposeVersion( - xCorrelationId = correlationId, - purposeId, - versionId, - stateChangeDetails, - xForwardedFor = ip - )(BearerToken(bearerToken)) + ): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => + val request = api.archivePurposeVersion(xCorrelationId = correlationId, purposeId, versionId, stateChangeDetails)( + BearerToken(bearerToken) + ) invoker.invoke(request, s"Archiving Version $versionId of Purpose $purposeId by ${stateChangeDetails.changedBy}") } @@ -181,34 +166,29 @@ final case class PurposeManagementServiceImpl(invoker: PurposeManagementInvoker, purposeId: UUID, versionId: UUID, updateContent: WaitingForApprovalPurposeVersionUpdateContent - )(implicit contexts: Seq[(String, String)]): Future[PurposeVersion] = withHeaders { - (bearerToken, correlationId, ip) => - val request = api.updateWaitingForApprovalPurposeVersion( - xCorrelationId = correlationId, - purposeId, - versionId, - updateContent, - xForwardedFor = ip - )(BearerToken(bearerToken)) - invoker.invoke( - request, - s"Updating waiting for approval version $versionId of Purpose $purposeId with $updateContent" + )(implicit contexts: Seq[(String, String)]): Future[PurposeVersion] = withHeaders { (bearerToken, correlationId) => + val request = + api.updateWaitingForApprovalPurposeVersion(xCorrelationId = correlationId, purposeId, versionId, updateContent)( + BearerToken(bearerToken) ) + invoker.invoke( + request, + s"Updating waiting for approval version $versionId of Purpose $purposeId with $updateContent" + ) } override def deletePurpose(purposeId: UUID)(implicit contexts: Seq[(String, String)]): Future[Unit] = withHeaders { - (bearerToken, correlationId, ip) => + (bearerToken, correlationId) => val request = - api.deletePurpose(xCorrelationId = correlationId, purposeId, xForwardedFor = ip)(BearerToken(bearerToken)) + api.deletePurpose(xCorrelationId = correlationId, purposeId)(BearerToken(bearerToken)) invoker.invoke(request, s"Deleting purpose $purposeId") } override def deletePurposeVersion(purposeId: UUID, versionId: UUID)(implicit contexts: Seq[(String, String)] - ): Future[Unit] = withHeaders { (bearerToken, correlationId, ip) => - val request = api.deletePurposeVersion(xCorrelationId = correlationId, purposeId, versionId, xForwardedFor = ip)( - BearerToken(bearerToken) - ) + ): Future[Unit] = withHeaders { (bearerToken, correlationId) => + val request = + api.deletePurposeVersion(xCorrelationId = correlationId, purposeId, versionId)(BearerToken(bearerToken)) invoker .invoke(request, s"Deleting purpose version $purposeId/$versionId") .recoverWith {