diff --git a/infrastructure/local/docker-compose.yml b/infrastructure/local/docker-compose.yml index c48c0f7194..842766fae4 100644 --- a/infrastructure/local/docker-compose.yml +++ b/infrastructure/local/docker-compose.yml @@ -12,8 +12,6 @@ services: POSTGRES_DB: castor POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 volumes: - pg_data_castor_db:/var/lib/postgresql/data @@ -36,8 +34,6 @@ services: POSTGRES_DB: pollux POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - ports: - - 5433:5432 volumes: - pg_data_pollux_db:/var/lib/postgresql/data @@ -49,6 +45,28 @@ services: db_pollux: condition: service_started + ########################## + # Connect Database + ########################## + + db_connect: + image: postgres:13 + restart: always + environment: + POSTGRES_DB: connect + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + volumes: + - pg_data_connect_db:/var/lib/postgresql/data + + # delay to ensure DB is up before applying migrations + db_connect_init_delay: + image: alpine:3 + command: sleep 5 + depends_on: + db_connect: + condition: service_started + ########################## # Iris Database ########################## @@ -60,8 +78,6 @@ services: POSTGRES_DB: iris POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - ports: - - 5434:5432 volumes: - pg_data_iris_db:/var/lib/postgresql/data @@ -78,12 +94,10 @@ services: # Services ########################## mediator: - image: ghcr.io/input-output-hk/mercury-mediator:0.1.0-SNAPSHOT + image: ghcr.io/input-output-hk/mercury-mediator:0.2.0 iris: - image: ghcr.io/input-output-hk/iris-service:0.1.0-SNAPSHOT - ports: - - 8081:8081 + image: ghcr.io/input-output-hk/iris-service:0.1.0 environment: IRIS_DB_HOST: db_iris IRIS_DB_PORT: 5432 @@ -91,7 +105,7 @@ services: IRIS_DB_USER: postgres prism-agent: - image: ghcr.io/input-output-hk/prism-agent:0.2.0-SNAPSHOT + image: ghcr.io/input-output-hk/prism-agent:0.6.0-SNAPSHOT environment: IRIS_HOST: iris IRIS_PORT: 8081 @@ -105,9 +119,12 @@ services: POLLUX_DB_NAME: pollux POLLUX_DB_USER: postgres POLLUX_DB_PASSWORD: postgres - ports: - - "8085:8085" - - "8080:8080" + CONNECT_DB_HOST: db_connect + CONNECT_DB_PORT: 5432 + CONNECT_DB_NAME: connect + CONNECT_DB_USER: postgres + CONNECT_DB_PASSWORD: postgres + DIDCOMM_SERVICE_URL: http://host.docker.internal:${PORT}/didcomm/ swagger-ui: image: swaggerapi/swagger-ui:v4.14.0 @@ -121,7 +138,7 @@ services: haproxy: image: haproxy:2.6.5 ports: - - "80:80" # Http + - "${PORT}:80" # Http depends_on: - mediator - prism-agent @@ -132,4 +149,5 @@ services: volumes: pg_data_castor_db: pg_data_pollux_db: + pg_data_connect_db: pg_data_iris_db: diff --git a/infrastructure/local/haproxy/haproxy.cfg b/infrastructure/local/haproxy/haproxy.cfg index 9437b6acb0..8701458eda 100644 --- a/infrastructure/local/haproxy/haproxy.cfg +++ b/infrastructure/local/haproxy/haproxy.cfg @@ -24,10 +24,11 @@ frontend https-in option httplog option logasap - use_backend mediator if { path_beg -i /mediator } - use_backend swagger-ui if { path_beg -i /apidocs } - use_backend prism-agent if { path_beg -i /prism-agent } - use_backend prism-agent-tapir if { path_beg -i /tapir } + use_backend mediator if { path_beg -i /mediator } + use_backend swagger-ui if { path_beg -i /apidocs } + use_backend prism-agent if { path_beg -i /prism-agent } + use_backend prism-agent-didcomm if { path_beg -i /didcomm } + use_backend prism-agent-tapir if { path_beg -i /tapir } backend mediator balance roundrobin @@ -43,6 +44,13 @@ backend prism-agent option forwardfor server s1 prism-agent:8080 maxconn 32 +backend prism-agent-didcomm + balance roundrobin + http-request set-uri %[url,regsub(^/didcomm,,)] if { path_beg /didcomm } + option httpclose + option forwardfor + server s1 prism-agent:8090 maxconn 32 + backend prism-agent-tapir balance roundrobin http-request set-uri %[url,regsub(^/tapir,,)] if { path_beg /tapir } diff --git a/prism-agent/service/README.md b/prism-agent/service/README.md index 7834ef3728..9e3fcb2d97 100644 --- a/prism-agent/service/README.md +++ b/prism-agent/service/README.md @@ -47,7 +47,14 @@ Similar to [Indy Wallet SDK - secret API](https://github.com/hyperledger/indy-sd *it does not expose a private-key* for external use, instead it provide functions to perform cryptographic actions using internally stored private-keys. --- +## Connect flow +Basic documentation on how to execute the Connect flow from command line can be found [here](./connect.md). +--- +## Issue flow +Basic documentation on how to execute the Issue flow from the command line can be found [here](./issue.md). + +--- ## Known limitations ### Castor `worker` process embedded inside `prism-agent` runnable diff --git a/prism-agent/service/connect.md b/prism-agent/service/connect.md new file mode 100644 index 0000000000..806b7f926a --- /dev/null +++ b/prism-agent/service/connect.md @@ -0,0 +1,51 @@ +### Running multiple instances of Prism Agent +--- + +#### Starting an instance for `Inviter` on port `8080` + +```bash +# From the root directory +PORT=8080 docker-compose -p inviter -f infrastructure/local/docker-compose.yml up +``` + +#### Starting an instance for `Invitee` on port `8090` + +```bash +# From the root directory +PORT=8090 docker-compose -p invitee -f infrastructure/local/docker-compose.yml up +``` + +### Executing the `Connect` flow +--- + +- **Inviter** - Create a connection record containing the invitation +```bash +curl -X 'POST' \ + 'http://localhost:8080/prism-agent/connections' \ + -H 'Content-Type: application/json' \ + -d '{ + "label": "Connect with Alice" + }' | jq +``` + +- **Inviter** - Retrieving the list of connections +```bash +curl -X 'GET' 'http://localhost:8080/prism-agent/connections' | jq +``` + +- **Invitee** - Accept OOB invitation + +Replace `{RAW_INVITATION}` with the value of the '_oob' query string parameter from the invitation URL above +```bash +curl -X 'POST' \ + 'http://localhost:8090/prism-agent/connection-invitations' \ + -H 'Content-Type: application/json' \ + -d '{ + "invitation": "{RAW_INVITATION}" + }' | jq +``` + +- **Invitee** - Retrieving the list of connections +```bash +curl -X 'GET' 'http://localhost:8090/prism-agent/connections' | jq +``` diff --git a/prism-agent/service/issue.md b/prism-agent/service/issue.md new file mode 100644 index 0000000000..ab727b85c8 --- /dev/null +++ b/prism-agent/service/issue.md @@ -0,0 +1,65 @@ +### Running multiple instances of Prism Agent +--- + +#### Starting an instance for `Issuer` on port `8080` + +```bash +# From the root directory +PORT=8080 docker-compose -p issuer -f infrastructure/local/docker-compose.yml up +``` + +#### Starting an instance for `Holder` on port `8090` + +```bash +# From the root directory +PORT=8090 docker-compose -p holder -f infrastructure/local/docker-compose.yml up +``` + +### Executing the `Issue` flow +--- + +- **Issuer** - Initiate a new issue credential flow + +Replace `{SUBJECT_ID}` with the DID of the holder displayed at startup in the his Prism Agent console logs +```bash +curl -X 'POST' \ + 'http://localhost:8080/prism-agent/issue-credentials/credential-offers' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "schemaId": "schema:1234", + "subjectId": "{SUBJECT_ID}", + "validityPeriod": 3600, + "automaticIssuance": false, + "awaitConfirmation": false, + "claims": { + "firstname": "Alice", + "lastname": "Wonderland", + "birthdate": "01/01/2000" + } + }' | jq +``` + +- **Holder** - Retrieving the list of issue records +```bash +curl -X 'GET' 'http://localhost:8090/prism-agent/issue-credentials/records' | jq +``` + +- **Holder** - Accepting the credential offer + +Replace `{RECORD_ID}` with the UUID of the record from the previous list +```bash +curl -X 'POST' 'http://localhost:8090/prism-agent/issue-credentials/records/{RECORD_ID}/accept-offer' | jq +``` + +- **Issuer** - Retrieving the list of issue records +```bash +curl -X 'GET' 'http://localhost:8080/prism-agent/issue-credentials/records' | jq +``` + +- **Issuer** - Issuing the credential + +Replace `{RECORD_ID}` with the UUID of the record from the previous list +```bash +curl -X 'POST' 'http://localhost:8080/prism-agent/issue-credentials/records/{RECORD_ID}/issue-credential' | jq +``` \ No newline at end of file diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Main.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Main.scala index 04c267982e..07a0ca1c45 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Main.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Main.scala @@ -67,7 +67,7 @@ object Main extends ZIOAppDefault { .provide(RepoModule.connectDbConfigLayer >>> ConnectMigrations.layer) agentDID <- for { - peer <- ZIO.succeed(PeerDID.makePeerDid(serviceEndpoint = Some(s"$didCommServiceUrl:$didCommServicePort"))) + peer <- ZIO.succeed(PeerDID.makePeerDid(serviceEndpoint = Some(didCommServiceUrl))) _ <- ZIO.logInfo(s"New DID: ${peer.did}") *> ZIO.logInfo(s"JWK for KeyAgreement: ${peer.jwkForKeyAgreement.toJSONString}") *> ZIO.logInfo(s"JWK for KeyAuthentication: ${peer.jwkForKeyAuthentication.toJSONString}") diff --git a/prism-agent/service/version.sbt b/prism-agent/service/version.sbt index 0908091720..5bf12846b2 100644 --- a/prism-agent/service/version.sbt +++ b/prism-agent/service/version.sbt @@ -1 +1 @@ -ThisBuild / version := "0.5.0-SNAPSHOT" +ThisBuild / version := "0.6.0-SNAPSHOT"