Skip to content

Commit

Permalink
PIN-4138 Rid of IpAddress header (#190)
Browse files Browse the repository at this point in the history
Co-authored-by: nttdata-rtorsoli <[email protected]>
  • Loading branch information
nttdata-rtorsoli and nttdata-rtorsoli authored Oct 31, 2023
1 parent 856ad61 commit 8b75279
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 84 deletions.
23 changes: 0 additions & 23 deletions src/main/resources/interface-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ paths:
/purposes:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
get:
tags:
- purpose
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -206,7 +202,6 @@ paths:
post:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
tags:
- purpose
operationId: updateReversePurpose
Expand All @@ -233,7 +228,6 @@ paths:
/purposes/{id}:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
- name: id
in: path
description: the purpose id
Expand Down Expand Up @@ -268,7 +262,6 @@ paths:
post:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
tags:
- purpose
operationId: updatePurpose
Expand All @@ -295,7 +288,6 @@ paths:
delete:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
tags:
- purpose
operationId: deletePurpose
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -359,7 +350,6 @@ paths:
/purposes/{purposeId}/versions/{versionId}:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
- name: purposeId
in: path
required: true
Expand Down Expand Up @@ -396,7 +386,6 @@ paths:
/purposes/{purposeId}/versions/{versionId}/documents/{documentId}:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
get:
security:
- bearerAuth: []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -501,7 +489,6 @@ paths:
/purposes/{purposeId}/clone:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
- name: purposeId
in: path
required: true
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -676,7 +660,6 @@ paths:
/purposes/riskAnalysis/latest:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
- name: tenantKind
in: query
schema:
Expand Down Expand Up @@ -708,7 +691,6 @@ paths:
/purposes/riskAnalysis/version/{riskAnalysisVersion}:
parameters:
- $ref: '#/components/parameters/CorrelationIdHeader'
- $ref: '#/components/parameters/IpAddress'
- name: riskAnalysisVersion
in: path
required: true
Expand Down Expand Up @@ -750,11 +732,6 @@ components:
required: true
schema:
type: string
IpAddress:
in: header
name: X-Forwarded-For
schema:
type: string
schemas:
TenantKind:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,26 @@ 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)) }
}

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")
}

Expand Down Expand Up @@ -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(
Expand All @@ -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}"
Expand All @@ -166,49 +155,40 @@ 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}")
}

override def updateWaitingForApprovalPurposeVersion(
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 {
Expand Down

0 comments on commit 8b75279

Please sign in to comment.