Skip to content

Commit

Permalink
feat(prism-agent): integrate VerificationPolicy DAL into the agent, u…
Browse files Browse the repository at this point in the history
…pdate OAS and implement REST API for verification policies (#369)
  • Loading branch information
yshyn-iohk committed Feb 13, 2023
1 parent 290a206 commit 142ff55
Show file tree
Hide file tree
Showing 16 changed files with 498 additions and 476 deletions.
58 changes: 30 additions & 28 deletions prism-agent/service/api/http/pollux/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ components:
items:
$ref: "#/components/schemas/VerifiableCredentialSchema"

VerificationPolicyConstraint:
required:
- schemaId
type: object
properties:
schemaId:
type: string
trustedIssuers:
type: array
items:
type: string

VerificationCredentialSchemaInput:
required:
- name
Expand Down Expand Up @@ -142,7 +154,9 @@ components:
- self
- kind
- id
- nonce
- name
- description
- createdAt
- updatedAt
type: object
Expand All @@ -153,54 +167,42 @@ components:
type: string
id:
type: string
format: uuid
nonce:
type: integer
format: int32
name:
type: string
attributes:
type: array
items:
type: string
issuerDIDs:
type: array
items:
type: string
credentialTypes:
type: array
items:
type: string
description:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
constraints:
type: array
items:
$ref: "#/components/schemas/VerificationPolicyConstraint"

VerificationPolicyInput:
required:
- name
- description
type: object
properties:
id:
type: string
format: uuid
name:
type: string
attributes:
type: array
items:
type: string
issuerDIDs:
type: array
items:
type: string
credentialTypes:
description:
type: string
constraints:
type: array
items:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
$ref: "#/components/schemas/VerificationPolicyConstraint"

VerificationPolicyPage:
required:
Expand Down
40 changes: 20 additions & 20 deletions prism-agent/service/api/http/prism-agent-openapi-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -335,30 +335,15 @@ paths:
- Verification
summary: Lookup verification policies by query
description:
Lookup verification policies by `name`, `attributes`, `issuerDIDs`,
and `credentialTypes` and control the pagination by `offset` and `limit` parameters
Lookup verification policies by `name`, and control the pagination
by `offset` and `limit` parameters
operationId: lookupVerificationPoliciesByQuery
parameters:
- name: name
in: query
required: false
schema:
type: string
- name: attributes
in: query
required: false
schema:
type: string
- name: issuerDIDs
in: query
required: false
schema:
type: string
- name: credentialTypes
in: query
required: false
schema:
type: string
- name: offset
in: query
required: false
Expand Down Expand Up @@ -441,6 +426,7 @@ paths:
required: true
schema:
type: string
format: uuid
responses:
"200":
description: ""
Expand Down Expand Up @@ -470,16 +456,22 @@ paths:
tags:
- Verification
summary: Update the verification policy object by id
description:
"Update the fields of the verification policy entry: `attributes`,
`issuerDIDs`, `name`, `credentialTypes`, "
description: Update the verification policy entry
operationId: updateVerificationPolicy
parameters:
- name: id
in: path
required: true
schema:
type: string
format: uuid
- name: nonce
in: query
description: Nonce of the previous VerificationPolicy
required: true
schema:
type: integer
format: int32
requestBody:
description: Update verification policy object
content:
Expand Down Expand Up @@ -525,6 +517,14 @@ paths:
required: true
schema:
type: string
format: uuid
- name: nonce
in: query
description: Nonce of the previous VerificationPolicy
required: true
schema:
type: integer
format: int32
responses:
"200":
description: ""
Expand Down
2 changes: 1 addition & 1 deletion prism-agent/service/project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Dependencies {
val akka = "2.6.20"
val akkaHttp = "10.2.9"
val castor = "0.8.0"
val pollux = "0.25.0"
val pollux = "0.26.0"
val connect = "0.10.0"
val bouncyCastle = "1.70"
val logback = "1.4.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import io.iohk.atala.agent.walletapi.service.ManagedDIDService
import io.iohk.atala.resolvers.DIDResolver
import io.iohk.atala.agent.server.http.ZioHttpClient
import org.flywaydb.core.extensibility.AppliedMigration
import io.iohk.atala.pollux.service.{
JdbcSchemaRegistryService,
SchemaRegistryServiceInMemory,
VerificationPolicyServiceInMemory
}
import io.iohk.atala.pollux.service.{JdbcSchemaRegistryService, SchemaRegistryServiceInMemory}
import io.iohk.atala.agent.walletapi.sql.JdbcDIDSecretStorage
import io.iohk.atala.pollux.schema.controller.VerificationPolicyControllerInMemory

object Main extends ZIOAppDefault {

Expand Down Expand Up @@ -101,10 +98,10 @@ object Main extends ZIOAppDefault {
SystemModule.actorSystemLayer,
HttpModule.layers,
RepoModule.credentialSchemaServiceLayer,
VerificationPolicyServiceInMemory.layer,
AppModule.manageDIDServiceLayer,
JdbcDIDSecretStorage.layer,
RepoModule.agentTransactorLayer
RepoModule.agentTransactorLayer,
RepoModule.verificationPolicyServiceLayer
)
} yield app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ package io.iohk.atala.agent.server

import io.iohk.atala.agent.server.Modules
import io.iohk.atala.mercury.*
import io.iohk.atala.pollux.schema.controller.VerificationPolicyControllerInMemory
import io.iohk.atala.resolvers.UniversalDidResolver
import org.didcommx.didcomm.DIDComm
import zio.*
import io.iohk.atala.pollux.service.SchemaRegistryServiceInMemory
import io.iohk.atala.pollux.service.VerificationPolicyServiceInMemory

object MainInMemory extends ZIOAppDefault {

override def run: ZIO[Any, Throwable, Unit] =
for {
_ <- Modules.zioApp
.provide(SchemaRegistryServiceInMemory.layer, VerificationPolicyServiceInMemory.layer, SystemModule.configLayer)
.provide(
SchemaRegistryServiceInMemory.layer,
VerificationPolicyControllerInMemory.layer,
SystemModule.configLayer
)
.fork
_ <- ZIO.never
} yield ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ import io.iohk.atala.agent.walletapi.model.error.DIDSecretStorageError
import io.iohk.atala.agent.server.http.marshaller.*
import io.iohk.atala.agent.server.http.service.*
import io.iohk.atala.agent.server.http.{HttpRoutes, HttpServer}
import io.iohk.atala.pollux.core.service.CredentialServiceImpl
import io.iohk.atala.pollux.core.service.{
CredentialService,
CredentialServiceImpl,
PresentationService,
PresentationServiceImpl,
VerificationPolicyService,
VerificationPolicyServiceImpl
}
import io.iohk.atala.iris.proto.service.IrisServiceGrpc
import io.iohk.atala.iris.proto.service.IrisServiceGrpc.IrisServiceStub
import io.iohk.atala.pollux.core.repository.CredentialRepository
import io.iohk.atala.pollux.core.service.CredentialService
import io.iohk.atala.pollux.sql.repository.JdbcCredentialRepository
import io.iohk.atala.pollux.sql.repository.DbConfig as PolluxDbConfig
import io.iohk.atala.pollux.sql.repository.{
JdbcCredentialRepository,
JdbcPresentationRepository,
JdbcVerificationPolicyRepository,
DbConfig as PolluxDbConfig
}
import io.iohk.atala.connect.sql.repository.DbConfig as ConnectDbConfig
import io.iohk.atala.agent.server.sql.DbConfig as AgentDbConfig
import io.iohk.atala.agent.server.jobs.*
Expand All @@ -47,7 +57,7 @@ import zhttp.service.Server

import java.util.concurrent.Executors
import io.iohk.atala.mercury.*
import io.iohk.atala.mercury.DidOps._
import io.iohk.atala.mercury.DidOps.*
import io.iohk.atala.mercury.model.*
import io.iohk.atala.mercury.model.error.*
import io.iohk.atala.mercury.protocol.issuecredential.*
Expand All @@ -57,16 +67,8 @@ import io.iohk.atala.prism.protos.node_api.NodeServiceGrpc
import java.io.IOException
import cats.implicits.*
import io.iohk.atala.pollux.schema.SchemaRegistryServerEndpoints
import io.iohk.atala.pollux.service.{
JdbcSchemaRegistryService,
SchemaRegistryService,
SchemaRegistryServiceInMemory,
VerificationPolicyServiceInMemory
}
import io.iohk.atala.pollux.core.service.PresentationService
import io.iohk.atala.pollux.core.service.PresentationServiceImpl
import io.iohk.atala.pollux.service.{JdbcSchemaRegistryService, SchemaRegistryService, SchemaRegistryServiceInMemory}
import io.iohk.atala.pollux.core.repository.PresentationRepository
import io.iohk.atala.pollux.sql.repository.JdbcPresentationRepository
import io.iohk.atala.pollux.core.model.error.PresentationError
import io.iohk.atala.pollux.core.model.error.CredentialServiceError
import io.iohk.atala.connect.core.service.ConnectionService
Expand All @@ -93,6 +95,11 @@ import io.iohk.atala.agent.walletapi.storage.DIDSecretStorage
import io.iohk.atala.pollux.vc.jwt.DidResolver as JwtDidResolver
import io.iohk.atala.pollux.vc.jwt.PrismDidResolver
import io.iohk.atala.mercury.DidAgent
import io.iohk.atala.pollux.schema.controller.{
VerificationPolicyController,
VerificationPolicyControllerImpl,
VerificationPolicyControllerInMemory
}

object Modules {

Expand All @@ -106,7 +113,7 @@ object Modules {
httpServerApp.unit
}

lazy val zioApp: RIO[SchemaRegistryService & VerificationPolicyServiceInMemory & AppConfig, Unit] = {
lazy val zioApp: RIO[SchemaRegistryService & VerificationPolicyController & AppConfig, Unit] = {
val zioHttpServerApp = for {
allSchemaRegistryEndpoints <- SchemaRegistryServerEndpoints.all
allVerificationPolicyEndpoints <- VerificationPolicyServerEndpoints.all
Expand Down Expand Up @@ -618,4 +625,9 @@ object RepoModule {
val credentialSchemaServiceLayer: TaskLayer[SchemaRegistryService] =
RepoModule.polluxTransactorLayer >>> JdbcSchemaRegistryService.layer

val verificationPolicyServiceLayer: TaskLayer[VerificationPolicyController] =
RepoModule.polluxTransactorLayer >>>
JdbcVerificationPolicyRepository.layer >+>
VerificationPolicyServiceImpl.layer >+>
VerificationPolicyControllerImpl.layer
}

0 comments on commit 142ff55

Please sign in to comment.