From 17c198e67fdcd5ebba0e68ea13de308b4db43f4a Mon Sep 17 00:00:00 2001 From: Richard Romanowski <79664656+rromanowski-figure@users.noreply.github.com> Date: Fri, 11 Aug 2023 14:48:53 -0400 Subject: [PATCH] Support authentication via Kong consumer headers (#112) --- .sdkmanrc | 1 + dc.sh | 17 +++++----- .../provenance/api/models/entity/EntityID.kt | 27 +++++++++++++++ .../api/models/p8e/query/QueryScopeRequest.kt | 3 +- service/docker/dependencies.yaml | 2 +- .../approve/ApproveContractBatchExecution.kt | 4 +-- .../cee/approve/ApproveContractExecution.kt | 4 +-- .../ApproveContractBatchRequestWrapper.kt | 4 +-- .../models/ApproveContractRequestWrapper.kt | 4 +-- .../usecase/cee/common/ContractUtilities.kt | 12 +++---- .../usecase/cee/common/client/CreateClient.kt | 7 +++- .../client/model/CreateClientRequest.kt | 4 +-- .../usecase/cee/execute/ExecuteContract.kt | 13 +++++-- .../cee/execute/ExecuteContractBatch.kt | 5 ++- .../ExecuteContractBatchRequestWrapper.kt | 4 +-- .../model/ExecuteContractRequestWrapper.kt | 4 +-- .../reject/RejectContractBatchExecution.kt | 2 +- .../cee/reject/RejectContractExecution.kt | 2 +- .../RejectContractBatchRequestWrapper.kt | 4 +-- .../RejectContractExecutionRequestWrapper.kt | 4 +-- .../SubmitContractBatchExecutionResult.kt | 2 +- .../submit/SubmitContractExecutionResult.kt | 2 +- ...tractBatchExecutionResultRequestWrapper.kt | 4 +-- ...itContractExecutionResultRequestWrapper.kt | 4 +-- .../common/originator/EntityManager.kt | 8 ++--- .../models/KeyManagementConfigWrapper.kt | 2 +- .../domain/usecase/objectStore/get/GetFile.kt | 2 +- .../usecase/objectStore/get/GetObject.kt | 2 +- .../usecase/objectStore/get/GetProto.kt | 2 +- .../get/models/GetFileRequestWrapper.kt | 4 +-- .../get/models/GetProtoRequestWrapper.kt | 4 +-- .../get/models/RetrieveAndDecryptRequest.kt | 4 +-- .../permissions/RegisterObjectAccess.kt | 2 +- .../permissions/RegisterScopeObjectsAccess.kt | 2 +- .../permissions/RevokeObjectAccess.kt | 2 +- .../permissions/RevokeScopeObjectsAccess.kt | 2 +- .../RegisterObjectAccessRequestWrapper.kt | 4 +-- ...egisterScopeObjectsAccessRequestWrapper.kt | 4 +-- .../model/RevokeObjectAccessRequestWrapper.kt | 4 +-- .../RevokeScopeObjectsAccessRequestWrapper.kt | 4 +-- .../objectStore/store/CreateGatewayJwt.kt | 2 +- .../usecase/objectStore/store/StoreFile.kt | 2 +- .../usecase/objectStore/store/StoreProto.kt | 2 +- .../store/models/CreateGatewayJwtRequest.kt | 4 +-- .../store/models/StoreFileRequestWrapper.kt | 3 +- .../store/models/StoreProtoRequestWrapper.kt | 4 +-- .../usecase/provenance/account/GetSigner.kt | 2 +- .../account/models/GetSignerRequest.kt | 34 +++++++++++++++++-- .../contracts/classify/ClassifyAsset.kt | 2 +- .../models/ClassifyAssetRequestWrapper.kt | 4 +-- .../fees/models/GetFeesForAssetRequest.kt | 4 +-- .../GetStatusOfClassificationRequest.kt | 3 +- .../contracts/verify/VerifyAsset.kt | 2 +- .../models/VerifyAssetRequestWrapper.kt | 4 +-- .../provenance/tx/execute/ExecuteTx.kt | 2 +- .../execute/models/ExecuteTxRequestWrapper.kt | 4 +-- .../tx/permissions/authz/UpdateAuthzGrant.kt | 4 +-- .../authz/models/UpdateAuthzRequestWrapper.kt | 4 +-- .../dataAccess/UpdateScopeDataAccess.kt | 4 +-- .../UpdateScopeDataAccessRequestWrapper.kt | 4 +-- .../permissions/fees/create/GrantFeeGrant.kt | 2 +- .../models/GrantFeeGrantRequestWrapper.kt | 4 +-- .../GetFeeGrantAllowanceRequestWrapper.kt | 4 +-- .../permissions/fees/revoke/RevokeFeeGrant.kt | 2 +- .../models/RevokeFeeGrantRequestWrapper.kt | 4 +-- .../tx/scope/ChangeScopeOwnership.kt | 2 +- ...ChangeScopeOwnershipBatchRequestWrapper.kt | 4 +-- .../ChangeScopeOwnershipRequestWrapper.kt | 8 ++--- .../api/frameworks/web/external/cee/CeeApi.kt | 1 + .../frameworks/web/external/cee/CeeHandler.kt | 25 +++++++++----- .../objectStore/ObjectStoreHandler.kt | 26 +++++++------- .../external/provenance/ProvenanceHandler.kt | 30 ++++++++-------- .../web/internal/cee/InternalCeeApi.kt | 2 +- .../web/internal/cee/InternalCeeHandler.kt | 10 +++--- .../objectStore/InternalObjectStoreHandler.kt | 18 +++++----- .../provenance/InternalProvenanceHandler.kt | 10 +++--- .../frameworks/web/misc/ServerRequestExt.kt | 27 ++++++++++++--- .../usecase/objectstore/StoreAssetTest.kt | 7 ++-- .../objectstore/ObjectStoreSpec.kt | 19 ++++++----- .../tx/ChangeScopeOwnershipTest.kt | 5 +-- service/src/test/resources/dependencies.yaml | 2 +- 81 files changed, 298 insertions(+), 199 deletions(-) create mode 100644 .sdkmanrc create mode 100644 models/src/main/kotlin/io/provenance/api/models/entity/EntityID.kt diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 00000000..2fe70516 --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1 @@ +java=11.0.20-tem diff --git a/dc.sh b/dc.sh index b216725b..f9631cf4 100755 --- a/dc.sh +++ b/dc.sh @@ -26,12 +26,12 @@ function up { docker-compose -p p8e-contract-execution-environment -f service/docker/dependencies.yaml up --build -d sleep 2 - sh service/docker/vault/init-and-unseal.sh 'http://127.0.0.1:8200' 'kv2_originations' - - sleep 2 - export VAULT_ADDR="http://127.0.0.1:8200" SECRET_PATH=kv2_originations + sh service/docker/vault/init-and-unseal.sh $VAULT_ADDR $SECRET_PATH + + until vault status; do echo "Awaiting vault to be unsealed..."; sleep 5; done + # local-originator cat service/docker/vault/secrets/local-originator.json | vault kv put $SECRET_PATH/originators/00000000-0000-0000-0000-000000000001 - > /dev/null cat service/docker/vault/secrets/local-originator.json | vault kv put $SECRET_PATH/originators/tp1qy2mqx5x22a400pgd5p6u7mq9shxzvh767jar0 - > /dev/null @@ -120,11 +120,10 @@ function build_classification() { } function setup() { - brew install docker - brew tap hashicorp/tap - brew install hashicorp/tap/vault - brew install rust - brew install jq + which -s docker || brew install docker + which -s vault || { brew tap hashicorp/tap; brew install hashicorp/tap/vault; } + which -s rust || brew install rust + which -s jq || brew install jq brew install coreutils } diff --git a/models/src/main/kotlin/io/provenance/api/models/entity/EntityID.kt b/models/src/main/kotlin/io/provenance/api/models/entity/EntityID.kt new file mode 100644 index 00000000..54748950 --- /dev/null +++ b/models/src/main/kotlin/io/provenance/api/models/entity/EntityID.kt @@ -0,0 +1,27 @@ +package io.provenance.api.models.entity + +import java.util.UUID + +sealed interface Entity { val id: String } + +/** + * Kong consumer + * + * @property id + * @property username - will be null for consumers created for delegated keys + * @property customId - contains granter address for delegated keys + * @constructor Create empty Kong consumer + */ +data class KongConsumer( + val entityId: String, + val username: String?, + val customId: String, +) : Entity { + override val id: String + get() = entityId +} + +data class MemberUUID(val value: UUID) : Entity { + override val id: String + get() = value.toString() +} diff --git a/models/src/main/kotlin/io/provenance/api/models/p8e/query/QueryScopeRequest.kt b/models/src/main/kotlin/io/provenance/api/models/p8e/query/QueryScopeRequest.kt index 46e1daf3..22a71b10 100644 --- a/models/src/main/kotlin/io/provenance/api/models/p8e/query/QueryScopeRequest.kt +++ b/models/src/main/kotlin/io/provenance/api/models/p8e/query/QueryScopeRequest.kt @@ -1,9 +1,10 @@ package io.provenance.api.models.p8e.query +import io.provenance.api.models.entity.Entity import java.util.UUID data class QueryScopeRequest( - val uuid: UUID, + val entity: Entity, val scopeUuid: UUID, val chainId: String, val nodeEndpoint: String, diff --git a/service/docker/dependencies.yaml b/service/docker/dependencies.yaml index 61bfb9b0..3059ec41 100644 --- a/service/docker/dependencies.yaml +++ b/service/docker/dependencies.yaml @@ -68,7 +68,7 @@ services: - provenance:/provenance vault: - image: vault:latest + image: hashicorp/vault:latest container_name: vault-cee networks: - p8e-network diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractBatchExecution.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractBatchExecution.kt index 2d39fc3b..932d1a5e 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractBatchExecution.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractBatchExecution.kt @@ -34,8 +34,8 @@ class ApproveContractBatchExecution( val responses = mutableListOf() val errors = mutableListOf() val executionResults = mutableListOf>>() - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) - createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).use { client -> + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) + createClient.execute(CreateClientRequest(args.entity, args.request.account, args.request.client)).use { client -> args.request.approvals.forEach { val envelope = Envelopes.Envelope.newBuilder().mergeFrom(it.envelope).build() diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractExecution.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractExecution.kt index 07222eec..c26fb973 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractExecution.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/ApproveContractExecution.kt @@ -26,12 +26,12 @@ class ApproveContractExecution( ) : AbstractUseCase() { override suspend fun execute(args: ApproveContractRequestWrapper): ApproveContractExecutionResponse { val envelope = Envelopes.Envelope.newBuilder().mergeFrom(args.request.approval.envelope).build() - createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).use { client -> + createClient.execute(CreateClientRequest(args.entity, args.request.account, args.request.client)).use { client -> val result = client.execute(envelope) if (result is FragmentResult) { val tx = client.approveScopeUpdate(result.envelopeState, args.request.approval.expiration).let { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) provenance.executeTransaction(args.request.provenanceConfig, it.toAny(), signer) } diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractBatchRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractBatchRequestWrapper.kt index 2e5c4396..b89db432 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractBatchRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractBatchRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.approve.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.approve.ApproveContractBatchRequest -import java.util.UUID data class ApproveContractBatchRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ApproveContractBatchRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractRequestWrapper.kt index 6aae2844..a117dd9e 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/approve/models/ApproveContractRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.approve.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.approve.ApproveContractRequest -import java.util.UUID data class ApproveContractRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ApproveContractRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/ContractUtilities.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/ContractUtilities.kt index d3d7752c..c18cb784 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/ContractUtilities.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/ContractUtilities.kt @@ -12,6 +12,7 @@ import io.provenance.api.models.account.Participant import io.provenance.api.models.cee.ParserConfig import io.provenance.api.models.cee.execute.ExecuteContractConfig import io.provenance.api.models.cee.execute.ScopeInfo +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.PermissionInfo import io.provenance.client.protobuf.extensions.isSet import io.provenance.metadata.v1.ScopeResponse @@ -20,11 +21,10 @@ import io.provenance.scope.contract.spec.P8eContract import io.provenance.scope.encryption.util.toJavaPublicKey import io.provenance.scope.sdk.Client import io.provenance.scope.sdk.Session -import java.util.UUID -import kotlin.reflect.KType -import kotlin.reflect.full.functions import mu.KotlinLogging import org.springframework.stereotype.Component +import kotlin.reflect.KType +import kotlin.reflect.full.functions @Component class ContractUtilities( @@ -36,12 +36,12 @@ class ContractUtilities( ) { private val log = KotlinLogging.logger { } - suspend fun createClient(uuid: UUID, permissions: PermissionInfo?, participants: List, config: ExecuteContractConfig): Client { + suspend fun createClient(entity: Entity, permissions: PermissionInfo?, participants: List, config: ExecuteContractConfig): Client { val audiences = entityManager.hydrateKeys(permissions, participants) - return createClient.execute(CreateClientRequest(uuid, config.account, config.client, audiences)) + return createClient.execute(CreateClientRequest(entity, config.account, config.client, audiences)) } - suspend fun createSession(uuid: UUID, client: Client, permissions: PermissionInfo?, participants: List, config: ExecuteContractConfig, records: Map, scopes: List): List { + suspend fun createSession(client: Client, permissions: PermissionInfo?, participants: List, config: ExecuteContractConfig, records: Map, scopes: List): List { val audiences = entityManager.hydrateKeys(permissions, participants) val contract = contractService.getContract(config.contract.contractName) val parsedRecords = getRecords(contractParser, records, contract, config.contract.parserConfig) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/CreateClient.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/CreateClient.kt index c6b4414b..9ea70d8f 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/CreateClient.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/CreateClient.kt @@ -21,7 +21,12 @@ class CreateClient( private val entityManager: EntityManager, ) : AbstractUseCase() { override suspend fun execute(args: CreateClientRequest): Client { - val originator = entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), args.account.keyManagementConfig)) + val originator = entityManager.getEntity( + KeyManagementConfigWrapper( + entityId = args.entity.id, + config = args.account.keyManagementConfig + ) + ) val affiliate = Affiliate( signingKeyRef = originator.getKeyRef(KeyType.SIGNING), encryptionKeyRef = originator.getKeyRef(KeyType.ENCRYPTION), diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/model/CreateClientRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/model/CreateClientRequest.kt index ab9e7501..a9b488b8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/model/CreateClientRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/common/client/model/CreateClientRequest.kt @@ -1,12 +1,12 @@ package io.provenance.api.domain.usecase.cee.common.client.model +import io.provenance.api.models.entity.Entity import io.provenance.api.models.account.AccountInfo import io.provenance.api.models.eos.ObjectStoreConfig import io.provenance.api.models.p8e.AudienceKeyPair -import java.util.UUID data class CreateClientRequest( - val uuid: UUID, + val entity: Entity, val account: AccountInfo = AccountInfo(), val client: ObjectStoreConfig, val affiliates: Set = emptySet() diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContract.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContract.kt index 11e71040..20330717 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContract.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContract.kt @@ -27,9 +27,16 @@ class ExecuteContract( ) : AbstractUseCase() { override suspend fun execute(args: ExecuteContractRequestWrapper): ContractExecutionResponse { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.config.account)) - contractUtilities.createClient(args.uuid, args.request.permissions, args.request.additionalParticipants, args.request.config).use { client -> - val session = contractUtilities.createSession(args.uuid, client, args.request.permissions, args.request.additionalParticipants, args.request.config, args.request.records, listOf(args.request.scope)).single() + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.config.account)) + contractUtilities.createClient(args.entity, args.request.permissions, args.request.additionalParticipants, args.request.config).use { client -> + val session = contractUtilities.createSession( + client = client, + permissions = args.request.permissions, + participants = args.request.additionalParticipants, + config = args.request.config, + records = args.request.records, + scopes = listOf(args.request.scope) + ).single() return when (val result = contractService.executeContract(client, session)) { is SignedResult -> { diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContractBatch.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContractBatch.kt index d8e34a96..8ebfc648 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContractBatch.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/ExecuteContractBatch.kt @@ -38,11 +38,10 @@ class ExecuteContractBatch( val pending = mutableListOf() val errors = mutableListOf() val results = mutableListOf>() - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.config.account)) - contractUtilities.createClient(args.uuid, args.request.permissions, args.request.additionalParticipants, args.request.config).use { client -> + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.config.account)) + contractUtilities.createClient(args.entity, args.request.permissions, args.request.additionalParticipants, args.request.config).use { client -> contractUtilities.createSession( - args.uuid, client, args.request.permissions, args.request.additionalParticipants, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractBatchRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractBatchRequestWrapper.kt index a3181743..e5b7a9f0 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractBatchRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractBatchRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.execute.model +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.execute.ExecuteContractBatchRequest -import java.util.UUID data class ExecuteContractBatchRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ExecuteContractBatchRequest, ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractRequestWrapper.kt index 4770d04e..528a98af 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/execute/model/ExecuteContractRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.execute.model +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.execute.ExecuteContractRequest -import java.util.UUID data class ExecuteContractRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ExecuteContractRequest, ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractBatchExecution.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractBatchExecution.kt index d58df4a1..98c507ec 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractBatchExecution.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractBatchExecution.kt @@ -12,7 +12,7 @@ class RejectContractBatchExecution( private val createClient: CreateClient ) : AbstractUseCase() { override suspend fun execute(args: RejectContractBatchRequestWrapper) { - createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).use { client -> + createClient.execute(CreateClientRequest(args.entity, args.request.account, args.request.client)).use { client -> args.request.rejection.forEach { val error = Envelopes.EnvelopeError.newBuilder().mergeFrom(it).build() client.respondWithError(error) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractExecution.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractExecution.kt index e591dfeb..0c18d6a8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractExecution.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/RejectContractExecution.kt @@ -14,7 +14,7 @@ class RejectContractExecution( override suspend fun execute(args: RejectContractExecutionRequestWrapper) { val error = Envelopes.EnvelopeError.newBuilder().mergeFrom(args.request.rejection).build() - createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).use { client -> + createClient.execute(CreateClientRequest(args.entity, args.request.account, args.request.client)).use { client -> client.respondWithError(error) } } diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractBatchRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractBatchRequestWrapper.kt index dc0aec82..45977ad8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractBatchRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractBatchRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.reject.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.reject.RejectContractBatchRequest -import java.util.UUID class RejectContractBatchRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RejectContractBatchRequest, ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractExecutionRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractExecutionRequestWrapper.kt index 17b7431a..b9e43426 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractExecutionRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/reject/models/RejectContractExecutionRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.reject.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.reject.RejectContractRequest -import java.util.UUID data class RejectContractExecutionRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RejectContractRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractBatchExecutionResult.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractBatchExecutionResult.kt index 3a949a3f..90282e93 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractBatchExecutionResult.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractBatchExecutionResult.kt @@ -31,7 +31,7 @@ class SubmitContractBatchExecutionResult( val signedResults = mutableListOf>() val response = mutableListOf() val errors = mutableListOf() - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) args.request.submission.forEach { val envelope = Envelopes.Envelope.newBuilder().mergeFrom(it.envelope).build() diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractExecutionResult.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractExecutionResult.kt index 2b2fa63e..f9814bc9 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractExecutionResult.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/SubmitContractExecutionResult.kt @@ -19,7 +19,7 @@ class SubmitContractExecutionResult( private val getSigner: GetSigner, ) : AbstractUseCase() { override suspend fun execute(args: SubmitContractExecutionResultRequestWrapper): TxResponse { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) val envelope = Envelopes.Envelope.newBuilder().mergeFrom(args.request.submission.envelope).build() val state = Envelopes.EnvelopeState.newBuilder().mergeFrom(args.request.submission.state).build() diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractBatchExecutionResultRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractBatchExecutionResultRequestWrapper.kt index e3195e13..467813b0 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractBatchExecutionResultRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractBatchExecutionResultRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.submit.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.submit.SubmitContractBatchExecutionResultRequest -import java.util.UUID data class SubmitContractBatchExecutionResultRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: SubmitContractBatchExecutionResultRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractExecutionResultRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractExecutionResultRequestWrapper.kt index c334e6e4..3b27316c 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractExecutionResultRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/cee/submit/models/SubmitContractExecutionResultRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.cee.submit.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.cee.submit.SubmitContractExecutionResultRequest -import java.util.UUID data class SubmitContractExecutionResultRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: SubmitContractExecutionResultRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/EntityManager.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/EntityManager.kt index 3da7c4b0..b7d6a506 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/EntityManager.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/EntityManager.kt @@ -26,14 +26,14 @@ class EntityManager( fun getEntity(args: KeyManagementConfigWrapper): KeyEntity { val config = args.config ?: KeyManagementConfig( pluginConfig = VaultConfig( - "${vaultProperties.address}/${args.entity}", + "${vaultProperties.address}/${args.entityId}", vaultProperties.tokenPath, ) ) val plugin = Class.forName(config.plugin).asSubclass(Plugin::class.java).kotlin.createInstance() manager.register(plugin) - return manager.get(args.entity, config.pluginConfig) + return manager.get(args.entityId, config.pluginConfig) } fun hydrateKeys(permissions: PermissionInfo?, participants: List = emptyList(), keyManagementConfig: KeyManagementConfig? = null): Set { @@ -53,8 +53,8 @@ class EntityManager( // Populate the audiences into the audience list permissions?.audiences?.forEach { - it.uuid?.let { entity -> - val keyEntity = getEntity(KeyManagementConfigWrapper(entity.toString(), keyManagementConfig)) + it.uuid?.let { uuid -> + val keyEntity = getEntity(KeyManagementConfigWrapper(uuid.toString(), keyManagementConfig)) additionalAudiences.add( AudienceKeyPair( diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/models/KeyManagementConfigWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/models/KeyManagementConfigWrapper.kt index 431df5c6..bd3767b2 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/models/KeyManagementConfigWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/common/originator/models/KeyManagementConfigWrapper.kt @@ -3,6 +3,6 @@ package io.provenance.api.domain.usecase.common.originator.models import io.provenance.api.models.account.KeyManagementConfig data class KeyManagementConfigWrapper( - val entity: String, + val entityId: String, val config: KeyManagementConfig? ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetFile.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetFile.kt index dcf6afba..6800bbdc 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetFile.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetFile.kt @@ -18,7 +18,7 @@ class GetFile( override suspend fun execute(args: GetFileRequestWrapper): Any { getObject.execute( RetrieveAndDecryptRequest( - args.uuid, + args.entity, args.request.objectStoreAddress, args.request.hash, args.request.accountInfo.keyManagementConfig, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetObject.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetObject.kt index 2e863fca..f1bfdd3e 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetObject.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetObject.kt @@ -22,7 +22,7 @@ class GetObject( private val provenanceProperties: ProvenanceProperties, ) : AbstractUseCase() { override suspend fun execute(args: RetrieveAndDecryptRequest): ByteArray { - val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), args.keyManagementConfig)) + val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.entity.id, args.keyManagementConfig)) if (args.useObjectStoreGateway) { GatewayClient(ClientConfig(URI.create(args.objectStoreAddress), provenanceProperties.mainnet)) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetProto.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetProto.kt index dc24d495..625ce841 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetProto.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/GetProto.kt @@ -14,7 +14,7 @@ class GetProto( override suspend fun execute(args: GetProtoRequestWrapper): String { val message = getObject.execute( RetrieveAndDecryptRequest( - args.uuid, + args.entity, args.request.objectStoreAddress, args.request.hash, args.request.account.keyManagementConfig, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetFileRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetFileRequestWrapper.kt index dd8d0656..99da513c 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetFileRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetFileRequestWrapper.kt @@ -1,10 +1,10 @@ package io.provenance.api.domain.usecase.objectStore.get.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.eos.get.GetFileRequest -import java.util.UUID data class GetFileRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: GetFileRequest, val useObjectStoreGateway: Boolean = false ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetProtoRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetProtoRequestWrapper.kt index 91c1a91b..7dad8c6b 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetProtoRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/GetProtoRequestWrapper.kt @@ -1,10 +1,10 @@ package io.provenance.api.domain.usecase.objectStore.get.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.eos.get.GetProtoRequest -import java.util.UUID data class GetProtoRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: GetProtoRequest, val useObjectStoreGateway: Boolean = false, ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/RetrieveAndDecryptRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/RetrieveAndDecryptRequest.kt index f08dbf38..890d3a15 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/RetrieveAndDecryptRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/get/models/RetrieveAndDecryptRequest.kt @@ -1,10 +1,10 @@ package io.provenance.api.domain.usecase.objectStore.get.models import io.provenance.api.models.account.KeyManagementConfig -import java.util.UUID +import io.provenance.api.models.entity.Entity data class RetrieveAndDecryptRequest( - val uuid: UUID, + val entity: Entity, val objectStoreAddress: String, val hash: String, val keyManagementConfig: KeyManagementConfig?, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterObjectAccess.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterObjectAccess.kt index 3d8a7756..c13106e9 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterObjectAccess.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterObjectAccess.kt @@ -19,7 +19,7 @@ class RegisterObjectAccess( val jwt = createGatewayJwt.execute( CreateGatewayJwtRequest( - args.uuid, + args.entity, args.request.accountInfo.keyManagementConfig ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterScopeObjectsAccess.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterScopeObjectsAccess.kt index bd8b79db..76cf4a2f 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterScopeObjectsAccess.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RegisterScopeObjectsAccess.kt @@ -20,7 +20,7 @@ class RegisterScopeObjectsAccess( override suspend fun execute(args: RegisterScopeObjectsAccessRequestWrapper) { val jwt = createGatewayJwt.execute( CreateGatewayJwtRequest( - args.uuid, + args.entity, args.request.accountInfo.keyManagementConfig ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeObjectAccess.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeObjectAccess.kt index 6d007020..cac882ae 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeObjectAccess.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeObjectAccess.kt @@ -18,7 +18,7 @@ class RevokeObjectAccess( override suspend fun execute(args: RevokeObjectAccessRequestWrapper) { val jwt = createGatewayJwt.execute( CreateGatewayJwtRequest( - args.uuid, + args.entity, args.request.accountInfo.keyManagementConfig ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeScopeObjectsAccess.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeScopeObjectsAccess.kt index 7c51eb97..6037f069 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeScopeObjectsAccess.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/RevokeScopeObjectsAccess.kt @@ -20,7 +20,7 @@ class RevokeScopeObjectsAccess( override suspend fun execute(args: RevokeScopeObjectsAccessRequestWrapper) { val jwt = createGatewayJwt.execute( CreateGatewayJwtRequest( - args.uuid, + args.entity, args.request.accountInfo.keyManagementConfig ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterObjectAccessRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterObjectAccessRequestWrapper.kt index 3837fbb1..44fac1f2 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterObjectAccessRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterObjectAccessRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.objectStore.permissions.model import io.provenance.api.models.eos.permissions.RegisterObjectAccessRequest -import java.util.UUID +import io.provenance.api.models.entity.Entity data class RegisterObjectAccessRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RegisterObjectAccessRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterScopeObjectsAccessRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterScopeObjectsAccessRequestWrapper.kt index 7d39bdcc..c38945ee 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterScopeObjectsAccessRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RegisterScopeObjectsAccessRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.objectStore.permissions.model +import io.provenance.api.models.entity.Entity import io.provenance.api.models.eos.permissions.RegisterScopeObjectsAccessRequest -import java.util.UUID data class RegisterScopeObjectsAccessRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RegisterScopeObjectsAccessRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeObjectAccessRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeObjectAccessRequestWrapper.kt index 0558d32e..10c6fa35 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeObjectAccessRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeObjectAccessRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.objectStore.permissions.model +import io.provenance.api.models.entity.Entity import io.provenance.api.models.eos.permissions.RevokeObjectAccessRequest -import java.util.UUID data class RevokeObjectAccessRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RevokeObjectAccessRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeScopeObjectsAccessRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeScopeObjectsAccessRequestWrapper.kt index 03519fea..40858fc5 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeScopeObjectsAccessRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/permissions/model/RevokeScopeObjectsAccessRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.objectStore.permissions.model import io.provenance.api.models.eos.permissions.RevokeScopeObjectsAccessRequest -import java.util.UUID +import io.provenance.api.models.entity.Entity data class RevokeScopeObjectsAccessRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RevokeScopeObjectsAccessRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/CreateGatewayJwt.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/CreateGatewayJwt.kt index 977b9a64..b4abf69d 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/CreateGatewayJwt.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/CreateGatewayJwt.kt @@ -13,7 +13,7 @@ class CreateGatewayJwt( private val entityManager: EntityManager ) : AbstractUseCase() { override suspend fun execute(args: CreateGatewayJwtRequest): GatewayJwt.KeyRefJwt { - val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), args.keyManagementConfig)) + val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.entity.id, args.keyManagementConfig)) return GatewayJwt.KeyRefJwt(entity.getKeyRef(KeyType.ENCRYPTION)) } diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreFile.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreFile.kt index 11d6e254..ef77ddf9 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreFile.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreFile.kt @@ -29,7 +29,7 @@ class StoreFile( ) : AbstractUseCase() { override suspend fun execute(args: StoreFileRequestWrapper): StoreProtoResponse { val (account, permissions, objectStoreAddress, storeRawBytes, id, file, type) = getParams(args.request) - val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), account?.keyManagementConfig)) + val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.entity.id, account?.keyManagementConfig)) return file.awaitAllBytes().map { bytes -> storeObject.executeBlocking( diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreProto.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreProto.kt index 25232150..1f4d581e 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreProto.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/StoreProto.kt @@ -18,7 +18,7 @@ class StoreProto( ) : AbstractUseCase() { override suspend fun execute(args: StoreProtoRequestWrapper): StoreProtoResponse { val asset = parser.parse(args.request.message, Class.forName(args.request.type)) - val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), args.request.account.keyManagementConfig)) + val entity = entityManager.getEntity(KeyManagementConfigWrapper(args.entity.id, args.request.account.keyManagementConfig)) return storeObject.execute( StoreObjectRequest( diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/CreateGatewayJwtRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/CreateGatewayJwtRequest.kt index 70e6c24b..f0d999b8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/CreateGatewayJwtRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/CreateGatewayJwtRequest.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.objectStore.store.models import io.provenance.api.models.account.KeyManagementConfig -import java.util.UUID +import io.provenance.api.models.entity.Entity data class CreateGatewayJwtRequest( - val uuid: UUID, + val entity: Entity, val keyManagementConfig: KeyManagementConfig? ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreFileRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreFileRequestWrapper.kt index 3055ac9e..9c758bb4 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreFileRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreFileRequestWrapper.kt @@ -1,11 +1,12 @@ package io.provenance.api.domain.usecase.objectStore.store.models +import io.provenance.api.models.entity.Entity import java.util.UUID import org.springframework.http.codec.multipart.FilePart import org.springframework.http.codec.multipart.Part data class StoreFileRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: Map, val useObjectStoreGateway: Boolean = false ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreProtoRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreProtoRequestWrapper.kt index 3311f8dd..9379f10a 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreProtoRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/objectStore/store/models/StoreProtoRequestWrapper.kt @@ -1,10 +1,10 @@ package io.provenance.api.domain.usecase.objectStore.store.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.eos.store.StoreProtoRequest -import java.util.UUID data class StoreProtoRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: StoreProtoRequest, val useObjectStoreGateway: Boolean = false ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/GetSigner.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/GetSigner.kt index 3c84699d..a9cc053b 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/GetSigner.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/GetSigner.kt @@ -18,7 +18,7 @@ class GetSigner( private val provenanceProperties: ProvenanceProperties, ) : AbstractUseCase() { override suspend fun execute(args: GetSignerRequest): Signer = - entityManager.getEntity(KeyManagementConfigWrapper(args.uuid.toString(), args.account.keyManagementConfig)).let { entity -> + entityManager.getEntity(KeyManagementConfigWrapper(args.entity, args.account.keyManagementConfig)).let { entity -> object : Signer { override fun address(): String = entity.address(KeyType.SIGNING, provenanceProperties.mainnet) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/models/GetSignerRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/models/GetSignerRequest.kt index d02786b6..3d2d52da 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/models/GetSignerRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/account/models/GetSignerRequest.kt @@ -1,9 +1,37 @@ package io.provenance.api.domain.usecase.provenance.account.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.account.AccountInfo +import io.provenance.api.models.entity.KongConsumer +import io.provenance.api.models.entity.MemberUUID import java.util.UUID -data class GetSignerRequest( - val uuid: UUID, +sealed interface GetSignerRequest { + + companion object { + operator fun invoke(id: Entity, account: AccountInfo): GetSignerRequest = when (id) { + is KongConsumer -> GetSignerByAddressRequest(id.customId, account) + is MemberUUID -> GetSignerByUUIDRequest(id.value, account) + } + } + val account: AccountInfo -) + + val entity: String +} + +data class GetSignerByUUIDRequest( + val uuid: UUID, + override val account: AccountInfo +) : GetSignerRequest { + override val entity: String + get() = uuid.toString() +} + +data class GetSignerByAddressRequest( + val address: String, + override val account: AccountInfo +) : GetSignerRequest { + override val entity: String + get() = address +} diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/ClassifyAsset.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/ClassifyAsset.kt index c4f45fca..84a2cf75 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/ClassifyAsset.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/ClassifyAsset.kt @@ -18,7 +18,7 @@ class ClassifyAsset( override suspend fun execute(args: ClassifyAssetRequestWrapper): TxResponse { val signer = getSigner.execute( GetSignerRequest( - args.uuid, + args.entity, args.request.account, ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/models/ClassifyAssetRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/models/ClassifyAssetRequestWrapper.kt index bedfca87..a686c68c 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/models/ClassifyAssetRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/classify/models/ClassifyAssetRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.contracts.classify.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.contracts.ClassifyAssetRequest -import java.util.UUID data class ClassifyAssetRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ClassifyAssetRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/fees/models/GetFeesForAssetRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/fees/models/GetFeesForAssetRequest.kt index ead5d14a..15454260 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/fees/models/GetFeesForAssetRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/fees/models/GetFeesForAssetRequest.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.contracts.fees.models -import java.util.UUID +import io.provenance.api.models.entity.Entity data class GetFeesForAssetRequest( - val uuid: UUID, + val entity: Entity, val contractName: String, val assetType: String, val chainId: String, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/status/models/GetStatusOfClassificationRequest.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/status/models/GetStatusOfClassificationRequest.kt index 74d0144b..a08c1b7b 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/status/models/GetStatusOfClassificationRequest.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/status/models/GetStatusOfClassificationRequest.kt @@ -1,9 +1,10 @@ package io.provenance.api.domain.usecase.provenance.contracts.status.models +import io.provenance.api.models.entity.Entity import java.util.UUID data class GetStatusOfClassificationRequest( - val uuid: UUID, + val entity: Entity, val assetUuid: UUID, val assetType: String, val contractName: String, diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/VerifyAsset.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/VerifyAsset.kt index 2a0f1e06..447eb7b6 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/VerifyAsset.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/VerifyAsset.kt @@ -18,7 +18,7 @@ class VerifyAsset( override suspend fun execute(args: VerifyAssetRequestWrapper): TxResponse { val signer = getSigner.execute( GetSignerRequest( - args.uuid, + args.entity, args.request.account, ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/models/VerifyAssetRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/models/VerifyAssetRequestWrapper.kt index 42e443ad..20e5bcc8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/models/VerifyAssetRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/contracts/verify/models/VerifyAssetRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.contracts.verify.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.contracts.VerifyAssetRequest -import java.util.UUID data class VerifyAssetRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: VerifyAssetRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/ExecuteTx.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/ExecuteTx.kt index 9c6e8cf8..48eb84bc 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/ExecuteTx.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/ExecuteTx.kt @@ -18,7 +18,7 @@ class ExecuteTx( private val getSigner: GetSigner, ) : AbstractUseCase() { override suspend fun execute(args: ExecuteTxRequestWrapper): TxResponse { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) val messages = args.request.tx.base64.map { tx -> Any.parseFrom(Base64.getDecoder().decode(tx)) } diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/models/ExecuteTxRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/models/ExecuteTxRequestWrapper.kt index d664fcb3..a1835fcc 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/models/ExecuteTxRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/execute/models/ExecuteTxRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.execute.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.ExecuteTxRequest -import java.util.UUID data class ExecuteTxRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ExecuteTxRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/UpdateAuthzGrant.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/UpdateAuthzGrant.kt index 21736aac..43522262 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/UpdateAuthzGrant.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/UpdateAuthzGrant.kt @@ -22,8 +22,8 @@ class UpdateAuthzGrant( private val getSigner: GetSigner ) : AbstractUseCase() { override suspend fun execute(args: UpdateAuthzRequestWrapper): TxResponse { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) - val messages = createClient.execute(CreateClientRequest(args.uuid, args.request.account, args.request.client)).use { client -> + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) + val messages = createClient.execute(CreateClientRequest(args.entity, args.request.account, args.request.client)).use { client -> args.request.changes.flatMap { change -> when (change.type) { AuthzChangeType.ADD -> { diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/models/UpdateAuthzRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/models/UpdateAuthzRequestWrapper.kt index ac9fe6d9..5d313833 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/models/UpdateAuthzRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/authz/models/UpdateAuthzRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.permissions.authz.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.permissions.authz.UpdateAuthzRequest -import java.util.UUID data class UpdateAuthzRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: UpdateAuthzRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/UpdateScopeDataAccess.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/UpdateScopeDataAccess.kt index ada0834d..90d6487c 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/UpdateScopeDataAccess.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/UpdateScopeDataAccess.kt @@ -32,7 +32,7 @@ class UpdateScopeDataAccess( private val createGatewayJwt: CreateGatewayJwt, ) : AbstractUseCase() { override suspend fun execute(args: UpdateScopeDataAccessRequestWrapper): TxResponse { - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) val messages = runActionForChange( args.request.changes, @@ -62,7 +62,7 @@ class UpdateScopeDataAccess( ) ) }?.use { client -> - val jwt = createGatewayJwt.execute(CreateGatewayJwtRequest(args.uuid, args.request.account.keyManagementConfig)) + val jwt = createGatewayJwt.execute(CreateGatewayJwtRequest(args.entity, args.request.account.keyManagementConfig)) runActionForChange( args.request.changes, { change -> client.grantScopePermission( diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/models/UpdateScopeDataAccessRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/models/UpdateScopeDataAccessRequestWrapper.kt index 54902c32..b79fb71d 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/models/UpdateScopeDataAccessRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/dataAccess/models/UpdateScopeDataAccessRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.permissions.dataAccess.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.permissions.dataAccess.UpdateScopeDataAccessRequest -import java.util.UUID data class UpdateScopeDataAccessRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: UpdateScopeDataAccessRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/GrantFeeGrant.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/GrantFeeGrant.kt index 869ca7ee..a585fda8 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/GrantFeeGrant.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/GrantFeeGrant.kt @@ -32,7 +32,7 @@ class GrantFeeGrant( val allowance = args.request.grant.allowance val signer = getSigner.execute( GetSignerRequest( - args.uuid, + args.entity, args.request.account ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/models/GrantFeeGrantRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/models/GrantFeeGrantRequestWrapper.kt index 7eb091bf..c977991c 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/models/GrantFeeGrantRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/create/models/GrantFeeGrantRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.permissions.fees.create.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.permissions.fees.grant.GrantFeeGrantRequest -import java.util.UUID data class GrantFeeGrantRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: GrantFeeGrantRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/get/models/GetFeeGrantAllowanceRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/get/models/GetFeeGrantAllowanceRequestWrapper.kt index a18573c2..ae171415 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/get/models/GetFeeGrantAllowanceRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/get/models/GetFeeGrantAllowanceRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.permissions.fees.get.models import io.provenance.api.models.p8e.tx.permissions.fees.get.GetFeeGrantAllowanceRequest -import java.util.UUID +import io.provenance.api.models.entity.Entity data class GetFeeGrantAllowanceRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: GetFeeGrantAllowanceRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/RevokeFeeGrant.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/RevokeFeeGrant.kt index c8f41557..3a02a82b 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/RevokeFeeGrant.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/RevokeFeeGrant.kt @@ -19,7 +19,7 @@ class RevokeFeeGrant( override suspend fun execute(args: RevokeFeeGrantRequestWrapper): TxResponse { val signer = getSigner.execute( GetSignerRequest( - args.uuid, + args.entity, args.request.account ) ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/models/RevokeFeeGrantRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/models/RevokeFeeGrantRequestWrapper.kt index ac869209..ffb60c5e 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/models/RevokeFeeGrantRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/permissions/fees/revoke/models/RevokeFeeGrantRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.permissions.fees.revoke.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.permissions.fees.revoke.RevokeFeeGrantRequest -import java.util.UUID class RevokeFeeGrantRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: RevokeFeeGrantRequest ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/ChangeScopeOwnership.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/ChangeScopeOwnership.kt index 2e411db6..d270c98f 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/ChangeScopeOwnership.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/ChangeScopeOwnership.kt @@ -30,7 +30,7 @@ class ChangeScopeOwnership( "Must request at least one change to the scope" } - val signer = getSigner.execute(GetSignerRequest(args.uuid, args.request.account)) + val signer = getSigner.execute(GetSignerRequest(args.entity, args.request.account)) val messages = args.request.scopeIds.distinct().map { val scopeResponse = provenance.getScope(args.request.provenanceConfig, it) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipBatchRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipBatchRequestWrapper.kt index 23a5c363..98e67814 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipBatchRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipBatchRequestWrapper.kt @@ -1,9 +1,9 @@ package io.provenance.api.domain.usecase.provenance.tx.scope.models +import io.provenance.api.models.entity.Entity import io.provenance.api.models.p8e.tx.ChangeScopeOwnershipBatchRequest -import java.util.UUID data class ChangeScopeOwnershipBatchRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ChangeScopeOwnershipBatchRequest, ) diff --git a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipRequestWrapper.kt b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipRequestWrapper.kt index 6159a98b..469c8e74 100644 --- a/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipRequestWrapper.kt +++ b/service/src/main/kotlin/io/provenance/api/domain/usecase/provenance/tx/scope/models/ChangeScopeOwnershipRequestWrapper.kt @@ -2,20 +2,20 @@ package io.provenance.api.domain.usecase.provenance.tx.scope.models import io.provenance.api.models.p8e.tx.ChangeScopeOwnershipBatchRequest import io.provenance.api.models.p8e.tx.ChangeScopeOwnershipRequest -import java.util.UUID +import io.provenance.api.models.entity.Entity data class ChangeScopeOwnershipRequestWrapper( - val uuid: UUID, + val entity: Entity, val request: ChangeScopeOwnershipRequest, ) { fun toBatchWrapper() = ChangeScopeOwnershipBatchRequestWrapper( - uuid, + entity, ChangeScopeOwnershipBatchRequest( request.account, request.provenanceConfig, listOf(request.scopeId), request.newValueOwner, request.newDataAccess - ) + ), ) } diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeApi.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeApi.kt index 10aced45..da5876b4 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeApi.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeApi.kt @@ -269,6 +269,7 @@ class CeeApi { POST("/execute", handler::executeContract) POST("/submit", handler::submitContractResult) POST("/reject", handler::rejectContractExecution) + GET("/headers", handler::showHeaders) "/batch".nest { POST("/execute", handler::executeContractBatch) POST("/submit", handler::submitContractBatchResult) diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeHandler.kt index 782861bc..293bb219 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/cee/CeeHandler.kt @@ -17,12 +17,15 @@ import io.provenance.api.domain.usecase.cee.submit.SubmitContractExecutionResult import io.provenance.api.domain.usecase.cee.submit.models.SubmitContractBatchExecutionResultRequestWrapper import io.provenance.api.domain.usecase.cee.submit.models.SubmitContractExecutionResultRequestWrapper import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity +import mu.KotlinLogging import org.springframework.stereotype.Component import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.ServerResponse import org.springframework.web.reactive.function.server.awaitBody +private val log = KotlinLogging.logger("CeeHandler") + @Component class CeeHandler( private val executeContract: ExecuteContract, @@ -35,34 +38,38 @@ class CeeHandler( private val rejectContractBatchExecution: RejectContractBatchExecution, ) { suspend fun executeContract(req: ServerRequest): ServerResponse = runCatching { - executeContract.execute(ExecuteContractRequestWrapper(req.getUser(), req.awaitBody())) + executeContract.execute(ExecuteContractRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun submitContractResult(req: ServerRequest): ServerResponse = runCatching { - submitContract.execute(SubmitContractExecutionResultRequestWrapper(req.getUser(), req.awaitBody())) + submitContract.execute(SubmitContractExecutionResultRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun approveContractExecution(req: ServerRequest): ServerResponse = runCatching { - approveContractExecution.execute(ApproveContractRequestWrapper(req.getUser(), req.awaitBody())) + approveContractExecution.execute(ApproveContractRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun rejectContractExecution(req: ServerRequest): ServerResponse = runCatching { - rejectContractExecution.execute(RejectContractExecutionRequestWrapper(req.getUser(), req.awaitBody())) + rejectContractExecution.execute(RejectContractExecutionRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun executeContractBatch(req: ServerRequest): ServerResponse = runCatching { - executeContractBatch.execute(ExecuteContractBatchRequestWrapper(req.getUser(), req.awaitBody())) + executeContractBatch.execute(ExecuteContractBatchRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun submitContractBatchResult(req: ServerRequest): ServerResponse = runCatching { - submitExecuteContractBatch.execute(SubmitContractBatchExecutionResultRequestWrapper(req.getUser(), req.awaitBody())) + submitExecuteContractBatch.execute(SubmitContractBatchExecutionResultRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun approveContractBatchExecution(req: ServerRequest): ServerResponse = runCatching { - approveContractBatchExecution.execute(ApproveContractBatchRequestWrapper(req.getUser(), req.awaitBody())) + approveContractBatchExecution.execute(ApproveContractBatchRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun rejectContractBatchExecution(req: ServerRequest): ServerResponse = runCatching { - rejectContractBatchExecution.execute(RejectContractBatchRequestWrapper(req.getUser(), req.awaitBody())) + rejectContractBatchExecution.execute(RejectContractBatchRequestWrapper(req.getEntity(), req.awaitBody())) + }.foldToServerResponse() + + suspend fun showHeaders(req: ServerRequest): ServerResponse = runCatching { + req.headers().also { log.info { "headers: $it" } } }.foldToServerResponse() } diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/objectStore/ObjectStoreHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/objectStore/ObjectStoreHandler.kt index e8a03e1b..d6f4848d 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/objectStore/ObjectStoreHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/objectStore/ObjectStoreHandler.kt @@ -18,7 +18,7 @@ import io.provenance.api.domain.usecase.objectStore.store.StoreProto import io.provenance.api.domain.usecase.objectStore.store.models.StoreFileRequestWrapper import io.provenance.api.domain.usecase.objectStore.store.models.StoreProtoRequestWrapper import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity import io.provenance.api.models.eos.get.GetFileRequest import io.provenance.api.models.eos.get.GetProtoRequest import io.provenance.api.models.eos.store.toModel @@ -45,7 +45,7 @@ class ObjectStoreHandler( suspend fun storeProto(req: ServerRequest): ServerResponse = runCatching { storeProto.execute( StoreProtoRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -54,7 +54,7 @@ class ObjectStoreHandler( suspend fun storeProtoV2(req: ServerRequest): ServerResponse = runCatching { storeProto.execute( StoreProtoRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody(), true ) @@ -64,7 +64,7 @@ class ObjectStoreHandler( suspend fun storeFile(req: ServerRequest): ServerResponse = runCatching { storeFile.execute( StoreFileRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitMultipartData().toSingleValueMap(), ) ) @@ -73,7 +73,7 @@ class ObjectStoreHandler( suspend fun storeFileV2(req: ServerRequest): ServerResponse = runCatching { storeFile.execute( StoreFileRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitMultipartData().toSingleValueMap(), true ) @@ -83,7 +83,7 @@ class ObjectStoreHandler( suspend fun getProto(req: ServerRequest): ServerResponse = runCatching { getProto.execute( GetProtoRequestWrapper( - req.getUser(), + req.getEntity(), GetProtoRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -96,7 +96,7 @@ class ObjectStoreHandler( suspend fun getProtoV2(req: ServerRequest): ServerResponse = runCatching { getProto.execute( GetProtoRequestWrapper( - req.getUser(), + req.getEntity(), GetProtoRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -110,7 +110,7 @@ class ObjectStoreHandler( suspend fun getFile(req: ServerRequest): ServerResponse = runCatching { getFile.execute( GetFileRequestWrapper( - req.getUser(), + req.getEntity(), GetFileRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -123,7 +123,7 @@ class ObjectStoreHandler( suspend fun getFileV2(req: ServerRequest): ServerResponse = runCatching { getFile.execute( GetFileRequestWrapper( - req.getUser(), + req.getEntity(), GetFileRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -141,7 +141,7 @@ class ObjectStoreHandler( suspend fun registerObjectAccess(req: ServerRequest): ServerResponse = runCatching { registerObjectAccess.execute( RegisterObjectAccessRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -150,7 +150,7 @@ class ObjectStoreHandler( suspend fun revokeObjectAccess(req: ServerRequest): ServerResponse = runCatching { revokeObjectAccess.execute( RevokeObjectAccessRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -159,7 +159,7 @@ class ObjectStoreHandler( suspend fun registerScopeObjectAccess(req: ServerRequest): ServerResponse = runCatching { registerScopeObjectsAccess.execute( RegisterScopeObjectsAccessRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -168,7 +168,7 @@ class ObjectStoreHandler( suspend fun revokeScopeObjectsAccess(req: ServerRequest): ServerResponse = runCatching { revokeScopeObjectsAccess.execute( RevokeScopeObjectsAccessRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/provenance/ProvenanceHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/provenance/ProvenanceHandler.kt index 83954423..f8983a00 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/external/provenance/ProvenanceHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/external/provenance/ProvenanceHandler.kt @@ -28,7 +28,7 @@ import io.provenance.api.domain.usecase.provenance.tx.scope.models.ChangeScopeOw import io.provenance.api.domain.usecase.provenance.tx.scope.models.ChangeScopeOwnershipRequestWrapper import io.provenance.api.frameworks.web.SuccessResponses import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity import io.provenance.api.models.account.AccountInfo import io.provenance.api.models.p8e.query.QueryScopeRequest import io.provenance.api.models.p8e.tx.permissions.fees.get.GetFeeGrantAllowanceRequest @@ -57,13 +57,13 @@ class ProvenanceHandler( private val revokeFeeGrant: RevokeFeeGrant, ) { suspend fun executeTx(req: ServerRequest): ServerResponse = runCatching { - executeTx.execute(ExecuteTxRequestWrapper(req.getUser(), req.awaitBody())) + executeTx.execute(ExecuteTxRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun queryScope(req: ServerRequest): ServerResponse = runCatching { queryScope.execute( QueryScopeRequest( - req.getUser(), + req.getEntity(), req.queryParam("scopeUuid").get().toUuid(), req.queryParam("chainId").get(), req.queryParam("nodeEndpoint").get(), @@ -75,7 +75,7 @@ class ProvenanceHandler( suspend fun changeScopeOwnership(req: ServerRequest): ServerResponse = runCatching { changeScopeOwnership.execute( ChangeScopeOwnershipRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody(), ).toBatchWrapper() ) @@ -84,24 +84,24 @@ class ProvenanceHandler( suspend fun changeScopeOwnershipBatch(req: ServerRequest): ServerResponse = runCatching { changeScopeOwnership.execute( ChangeScopeOwnershipBatchRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody(), ) ) }.foldToServerResponse() suspend fun classifyAsset(req: ServerRequest): ServerResponse = runCatching { - classifyAsset.execute(ClassifyAssetRequestWrapper(req.getUser(), req.awaitBody())) + classifyAsset.execute(ClassifyAssetRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun verifyAsset(req: ServerRequest): ServerResponse = runCatching { - verifyAsset.execute(VerifyAssetRequestWrapper(req.getUser(), req.awaitBody())) + verifyAsset.execute(VerifyAssetRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun getFees(req: ServerRequest): ServerResponse = runCatching { getFees.execute( GetFeesForAssetRequest( - req.getUser(), + req.getEntity(), req.queryParam("contractName").get(), req.queryParam("assetType").get(), req.queryParam("chainId").get(), @@ -113,7 +113,7 @@ class ProvenanceHandler( suspend fun getClassificationStatus(req: ServerRequest): ServerResponse = runCatching { getClassificationStatus.execute( GetStatusOfClassificationRequest( - req.getUser(), + req.getEntity(), req.queryParam("assetUuid").get().toUuid(), req.queryParam("assetType").get(), req.queryParam("contractName").get(), @@ -126,7 +126,7 @@ class ProvenanceHandler( suspend fun updateDataAccess(req: ServerRequest): ServerResponse = runCatching { updateDataAccess.execute( UpdateScopeDataAccessRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -135,7 +135,7 @@ class ProvenanceHandler( suspend fun updateAuthz(req: ServerRequest): ServerResponse = runCatching { updateAuthzGrant.execute( UpdateAuthzRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -144,7 +144,7 @@ class ProvenanceHandler( suspend fun checkCustody(req: ServerRequest): ServerResponse = kotlin.runCatching { getSigner.execute( GetSignerRequest( - uuid = req.getUser(), + id = req.getEntity(), account = req.awaitBodyOrNull() ?: AccountInfo() ) ) @@ -160,7 +160,7 @@ class ProvenanceHandler( suspend fun createFeesGrant(req: ServerRequest): ServerResponse = runCatching { grantFeeGrant.execute( GrantFeeGrantRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -169,7 +169,7 @@ class ProvenanceHandler( suspend fun revokeFeesGrant(req: ServerRequest): ServerResponse = runCatching { revokeFeeGrant.execute( RevokeFeeGrantRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -178,7 +178,7 @@ class ProvenanceHandler( suspend fun getFeeGrant(req: ServerRequest): ServerResponse = runCatching { getFeeGrant.execute( GetFeeGrantAllowanceRequestWrapper( - req.getUser(), + req.getEntity(), GetFeeGrantAllowanceRequest( nodeEndpoint = req.queryParam("nodeEndpoint").get(), chainId = req.queryParam("chainId").get(), diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeApi.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeApi.kt index fb76fe4f..333bcc96 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeApi.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeApi.kt @@ -7,7 +7,7 @@ import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.web.reactive.function.server.coRouter -private val log = KotlinLogging.logger {} +private val log = KotlinLogging.logger("InternalCeeApi") @Configuration class InternalCeeApi { diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeHandler.kt index 4ae0808d..b9d75e5b 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/cee/InternalCeeHandler.kt @@ -9,7 +9,7 @@ import io.provenance.api.domain.usecase.cee.reject.models.RejectContractExecutio import io.provenance.api.domain.usecase.cee.submit.SubmitContractExecutionResult import io.provenance.api.domain.usecase.cee.submit.models.SubmitContractExecutionResultRequestWrapper import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity import org.springframework.stereotype.Component import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.ServerResponse @@ -23,18 +23,18 @@ class InternalCeeHandler( private val submitContract: SubmitContractExecutionResult ) { suspend fun executeContract(req: ServerRequest): ServerResponse = runCatching { - executeContract.execute(ExecuteContractRequestWrapper(req.getUser(), req.awaitBody())) + executeContract.execute(ExecuteContractRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun submitContractResult(req: ServerRequest): ServerResponse = runCatching { - submitContract.execute(SubmitContractExecutionResultRequestWrapper(req.getUser(), req.awaitBody())) + submitContract.execute(SubmitContractExecutionResultRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun approveContractExecution(req: ServerRequest): ServerResponse = runCatching { - approveContractExecution.execute(ApproveContractRequestWrapper(req.getUser(), req.awaitBody())) + approveContractExecution.execute(ApproveContractRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun rejectContractExecution(req: ServerRequest): ServerResponse = runCatching { - rejectContractExecution.execute(RejectContractExecutionRequestWrapper(req.getUser(), req.awaitBody())) + rejectContractExecution.execute(RejectContractExecutionRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() } diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/objectStore/InternalObjectStoreHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/objectStore/InternalObjectStoreHandler.kt index 85e900cb..bd3e1f43 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/objectStore/InternalObjectStoreHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/objectStore/InternalObjectStoreHandler.kt @@ -9,7 +9,7 @@ import io.provenance.api.domain.usecase.objectStore.store.StoreProto import io.provenance.api.domain.usecase.objectStore.store.models.StoreFileRequestWrapper import io.provenance.api.domain.usecase.objectStore.store.models.StoreProtoRequestWrapper import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity import io.provenance.api.models.eos.get.GetFileRequest import io.provenance.api.models.eos.get.GetProtoRequest import io.provenance.api.models.eos.store.toModel @@ -30,7 +30,7 @@ class InternalObjectStoreHandler( suspend fun storeProto(req: ServerRequest): ServerResponse = runCatching { storeProto.execute( StoreProtoRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody() ) ) @@ -39,7 +39,7 @@ class InternalObjectStoreHandler( suspend fun storeFile(req: ServerRequest): ServerResponse = runCatching { storeFile.execute( StoreFileRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitMultipartData().toSingleValueMap() ) ) @@ -48,7 +48,7 @@ class InternalObjectStoreHandler( suspend fun getProto(req: ServerRequest): ServerResponse = runCatching { getProto.execute( GetProtoRequestWrapper( - req.getUser(), + req.getEntity(), GetProtoRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -61,7 +61,7 @@ class InternalObjectStoreHandler( suspend fun getFile(req: ServerRequest): ServerResponse = runCatching { getFile.execute( GetFileRequestWrapper( - req.getUser(), + req.getEntity(), GetFileRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -74,7 +74,7 @@ class InternalObjectStoreHandler( suspend fun storeProtoV2(req: ServerRequest): ServerResponse = runCatching { storeProto.execute( StoreProtoRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitBody(), true ) @@ -84,7 +84,7 @@ class InternalObjectStoreHandler( suspend fun storeFileV2(req: ServerRequest): ServerResponse = runCatching { storeFile.execute( StoreFileRequestWrapper( - req.getUser(), + req.getEntity(), req.awaitMultipartData().toSingleValueMap(), true ) @@ -94,7 +94,7 @@ class InternalObjectStoreHandler( suspend fun getProtoV2(req: ServerRequest): ServerResponse = runCatching { getProto.execute( GetProtoRequestWrapper( - req.getUser(), + req.getEntity(), GetProtoRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), @@ -108,7 +108,7 @@ class InternalObjectStoreHandler( suspend fun getFileV2(req: ServerRequest): ServerResponse = runCatching { getFile.execute( GetFileRequestWrapper( - req.getUser(), + req.getEntity(), GetFileRequest( req.queryParam("hash").get(), req.queryParam("objectStoreAddress").get(), diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/provenance/InternalProvenanceHandler.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/provenance/InternalProvenanceHandler.kt index ec82f7ab..8d8dc992 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/provenance/InternalProvenanceHandler.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/internal/provenance/InternalProvenanceHandler.kt @@ -11,7 +11,7 @@ import io.provenance.api.domain.usecase.provenance.contracts.status.models.GetSt import io.provenance.api.domain.usecase.provenance.contracts.verify.VerifyAsset import io.provenance.api.domain.usecase.provenance.contracts.verify.models.VerifyAssetRequestWrapper import io.provenance.api.frameworks.web.misc.foldToServerResponse -import io.provenance.api.frameworks.web.misc.getUser +import io.provenance.api.frameworks.web.misc.getEntity import io.provenance.scope.util.toUuid import org.springframework.stereotype.Component import org.springframework.web.reactive.function.server.ServerRequest @@ -27,17 +27,17 @@ class InternalProvenanceHandler( private val getAssetDefinitions: GetAssetDefinitions ) { suspend fun classifyAsset(req: ServerRequest): ServerResponse = runCatching { - classifyAsset.execute(ClassifyAssetRequestWrapper(req.getUser(), req.awaitBody())) + classifyAsset.execute(ClassifyAssetRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun verifyAsset(req: ServerRequest): ServerResponse = runCatching { - verifyAsset.execute(VerifyAssetRequestWrapper(req.getUser(), req.awaitBody())) + verifyAsset.execute(VerifyAssetRequestWrapper(req.getEntity(), req.awaitBody())) }.foldToServerResponse() suspend fun getClassificationStatus(req: ServerRequest): ServerResponse = runCatching { getClassificationStatus.execute( GetStatusOfClassificationRequest( - req.getUser(), + req.getEntity(), req.queryParam("assetUuid").get().toUuid(), req.queryParam("assetType").get(), req.queryParam("contractName").get(), @@ -50,7 +50,7 @@ class InternalProvenanceHandler( suspend fun getFees(req: ServerRequest): ServerResponse = runCatching { getFees.execute( GetFeesForAssetRequest( - req.getUser(), + req.getEntity(), req.queryParam("contractName").get(), req.queryParam("assetType").get(), req.queryParam("chainId").get(), diff --git a/service/src/main/kotlin/io/provenance/api/frameworks/web/misc/ServerRequestExt.kt b/service/src/main/kotlin/io/provenance/api/frameworks/web/misc/ServerRequestExt.kt index 4cf26286..77f33eab 100644 --- a/service/src/main/kotlin/io/provenance/api/frameworks/web/misc/ServerRequestExt.kt +++ b/service/src/main/kotlin/io/provenance/api/frameworks/web/misc/ServerRequestExt.kt @@ -1,5 +1,8 @@ package io.provenance.api.frameworks.web.misc +import io.provenance.api.models.entity.Entity +import io.provenance.api.models.entity.KongConsumer +import io.provenance.api.models.entity.MemberUUID import mu.KotlinLogging import org.springframework.web.reactive.function.server.ServerRequest import org.springframework.web.reactive.function.server.awaitBodyOrNull @@ -17,12 +20,26 @@ suspend inline fun ServerRequest.requireBody(): T = requireNotNull(awaitBodyOrNull()) { "Failed to parse request body of type ${T::class}" } } -fun ServerRequest.getUser(): UUID { +fun ServerRequest.getEntity(): Entity { try { - val header = requireNotNull(headers().firstHeader("x-uuid")) - return UUID.fromString(header) + return requireNotNull(getMemberUUIDOrNull() ?: getConsumerOrNull()) } catch (exception: IllegalArgumentException) { - log.error(exception) { "error parsing x-uuid header" } - throw IllegalArgumentException("error parsing x-uuid header", exception) + log.error(exception) { "error parsing headers for entity (x-uuid and x-consumer-id)" } + throw IllegalArgumentException("error parsing headers for entity (x-uuid and x-consumer-id)", exception) + } +} + +private fun ServerRequest.getMemberUUIDOrNull(): MemberUUID? = headers().firstHeader("x-uuid") + ?.let { MemberUUID(UUID.fromString(it)) } + +private fun ServerRequest.getConsumerOrNull(): KongConsumer? { + return headers().firstHeader("x-consumer-id")?.let { id -> + KongConsumer( + entityId = id, + username = headers().firstHeader("x-consumer-username"), + customId = requireNotNull(headers().firstHeader("x-consumer-custom-id")) { + "Custom ID for consumer (x-consumer-custom-id) missing" + }, + ) } } diff --git a/service/src/test/kotlin/io/provenance/api/domain/usecase/objectstore/StoreAssetTest.kt b/service/src/test/kotlin/io/provenance/api/domain/usecase/objectstore/StoreAssetTest.kt index 48044b7a..dd5f7b12 100644 --- a/service/src/test/kotlin/io/provenance/api/domain/usecase/objectstore/StoreAssetTest.kt +++ b/service/src/test/kotlin/io/provenance/api/domain/usecase/objectstore/StoreAssetTest.kt @@ -15,6 +15,7 @@ import io.provenance.api.domain.usecase.objectStore.store.models.StoreProtoReque import io.provenance.api.frameworks.cee.parsers.MessageParser import io.provenance.api.frameworks.config.ObjectStoreProperties import io.provenance.api.models.account.AccountInfo +import io.provenance.api.models.entity.MemberUUID import io.provenance.api.models.eos.store.StoreProtoRequest import io.provenance.api.models.eos.store.StoreProtoResponse import io.provenance.api.models.p8e.Audience @@ -25,10 +26,10 @@ import io.provenance.scope.encryption.model.DirectKeyRef import io.provenance.scope.encryption.util.toJavaPublicKey import io.provenance.scope.objectstore.client.OsClient import io.provenance.scope.util.toUuid -import java.security.PrivateKey -import java.security.PublicKey import org.junit.jupiter.api.Assertions.assertEquals import tech.figure.asset.v1beta1.Asset +import java.security.PrivateKey +import java.security.PublicKey const val ADD_ASSET_OBJECT_STORE_ADDRESS = "grpc://localhost:5005" const val ADD_ASSET_AUDIENCE_PUBLIC_KEY = @@ -84,7 +85,7 @@ class StoreAssetTest : FunSpec({ // Execute enable replication code val response = storeAsset.execute( StoreProtoRequestWrapper( - REQUEST_UUID, + MemberUUID(REQUEST_UUID), StoreProtoRequest( ADD_ASSET_OBJECT_STORE_ADDRESS, PermissionInfo( diff --git a/service/src/test/kotlin/io/provenance/api/integration/objectstore/ObjectStoreSpec.kt b/service/src/test/kotlin/io/provenance/api/integration/objectstore/ObjectStoreSpec.kt index 0ac184ca..f041472d 100644 --- a/service/src/test/kotlin/io/provenance/api/integration/objectstore/ObjectStoreSpec.kt +++ b/service/src/test/kotlin/io/provenance/api/integration/objectstore/ObjectStoreSpec.kt @@ -10,9 +10,10 @@ import io.provenance.api.models.account.AccountInfo import io.provenance.api.models.account.KeyManagementConfig import io.provenance.api.models.eos.get.GetProtoRequest import io.provenance.api.models.eos.store.StoreProtoRequest +import io.provenance.api.models.entity.Entity +import io.provenance.api.models.entity.MemberUUID import io.provenance.api.util.toPrettyJson import io.provenance.plugins.vault.VaultConfig -import io.provenance.scope.util.toUuid import java.util.UUID import tech.figure.asset.v1beta1.Asset import tech.figure.proto.util.toProtoUUID @@ -22,12 +23,14 @@ class ObjectStoreSpec( private val getProto: GetProto, ) : IntegrationTestBase({ - val entities = listOf( - "deadbeef-face-479b-860c-facefaceface".toUuid(), - "deadbeef-face-2222-860c-facefaceface".toUuid() + val entities = listOf( + MemberUUID(UUID.fromString("deadbeef-face-479b-860c-facefaceface")), + MemberUUID(UUID.fromString("deadbeef-face-2222-860c-facefaceface")), ) "Object Store" should { + val entity = entities.first() + "Store Object and Return Hash" { val assetToStore = Asset.newBuilder() .setDescription("arvo") @@ -37,7 +40,7 @@ class ObjectStoreSpec( val response = storeProto.execute( StoreProtoRequestWrapper( - entities.first(), + entity, StoreProtoRequest( objectStoreAddress = objectStoreAddress, message = assetToStore, @@ -45,7 +48,7 @@ class ObjectStoreSpec( account = AccountInfo( keyManagementConfig = KeyManagementConfig( pluginConfig = VaultConfig( - "$vaultAddress/${entities.first()}", + "$vaultAddress/${entity.id}", "src/test/resources/vault/token.output" ) ) @@ -56,7 +59,7 @@ class ObjectStoreSpec( val retrievedAsset = getProto.execute( GetProtoRequestWrapper( - entities.first(), + entity, GetProtoRequest( response.hash, objectStoreAddress, @@ -64,7 +67,7 @@ class ObjectStoreSpec( account = AccountInfo( keyManagementConfig = KeyManagementConfig( pluginConfig = VaultConfig( - "$vaultAddress/${entities.first()}", + "$vaultAddress/${entity.id}", "src/test/resources/vault/token.output" ) ) diff --git a/service/src/test/kotlin/io/provenance/api/integration/tx/ChangeScopeOwnershipTest.kt b/service/src/test/kotlin/io/provenance/api/integration/tx/ChangeScopeOwnershipTest.kt index 0260d53d..371f43d1 100644 --- a/service/src/test/kotlin/io/provenance/api/integration/tx/ChangeScopeOwnershipTest.kt +++ b/service/src/test/kotlin/io/provenance/api/integration/tx/ChangeScopeOwnershipTest.kt @@ -7,19 +7,20 @@ import io.provenance.api.domain.usecase.provenance.tx.scope.models.ChangeScopeOw import io.provenance.api.integration.base.IntegrationTestBase import io.provenance.api.models.p8e.ProvenanceConfig import io.provenance.api.models.p8e.tx.ChangeScopeOwnershipRequest +import io.provenance.api.models.entity.MemberUUID import io.provenance.scope.util.toUuid import java.util.UUID class ChangeScopeOwnershipTest( private val changeScopeOwnership: ChangeScopeOwnership, ) : IntegrationTestBase({ - val testEntityId = "deadbeef-face-479b-860c-facefaceface".toUuid() + val testEntity = MemberUUID("deadbeef-face-479b-860c-facefaceface".toUuid()) "Changing scope ownership" should { "throw an exception when no changes to the scope are specified" { shouldThrow { changeScopeOwnership.execute( ChangeScopeOwnershipRequestWrapper( - testEntityId, + testEntity, ChangeScopeOwnershipRequest( provenanceConfig = ProvenanceConfig( chainId = "chain-local", diff --git a/service/src/test/resources/dependencies.yaml b/service/src/test/resources/dependencies.yaml index 3c09f4af..f108f2b5 100644 --- a/service/src/test/resources/dependencies.yaml +++ b/service/src/test/resources/dependencies.yaml @@ -66,7 +66,7 @@ services: - provenance:/provenance vault: - image: vault:latest + image: hashicorp/vault:latest networks: - p8e-network-test ports: