Skip to content

Commit 8ba17e3

Browse files
authored
Merge branch 'main' into endorser-write-did
2 parents d850309 + 2dafaaa commit 8ba17e3

7 files changed

Lines changed: 205 additions & 5 deletions

File tree

aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ async def receive_credential(
503503

504504
# Remove values from cred that are not part of detail
505505
cred_dict.pop("proof")
506-
credential_status = cred_dict.pop("credentialStatus", None)
506+
credential_status = cred_dict.get("credentialStatus", None)
507507
detail_status = detail.options.credential_status
508508

509509
if cred_dict != detail_dict["credential"]:

aries_cloudagent/protocols/issue_credential/v2_0/formats/ld_proof/tests/test_handler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,14 @@ async def test_receive_credential_x_credential_status_ne(self):
770770

771771
async def test_receive_credential_x_credential_status_ne_both_set(self):
772772
detail = deepcopy(LD_PROOF_VC_DETAIL)
773+
status_entry = {"type": "SomeRandomType"}
773774

774-
# Set credential status so it's only set on the detail
775-
# not the issued credential
775+
# Set credential status in both request and reference credential
776776
detail["options"]["credentialStatus"] = {"type": "CredentialStatusType"}
777+
detail["credential"]["credentialStatus"] = deepcopy(status_entry)
777778

778779
vc = deepcopy(LD_PROOF_VC)
779-
vc["credentialStatus"] = {"type": "SomeRandomType"}
780+
vc["credentialStatus"] = deepcopy(status_entry)
780781

781782
cred_issue = V20CredIssue(
782783
formats=[

demo/docker-agent/Dockerfile.acapy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM bcgovimages/aries-cloudagent:py36-1.16-1_1.0.0-rc0
2+
3+
USER root
4+
5+
ADD https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 ./jq
6+
RUN chmod +x ./jq
7+
COPY ngrok-wait.sh ngrok-wait.sh
8+
RUN chmod +x ./ngrok-wait.sh
9+
10+
USER $user
11+
12+
# temporary until this PR gets merged/released
13+
RUN pip uninstall -y aries-cloudagent
14+
RUN pip install aries-cloudagent[indy,bbs,askar]@git+https://github.com/ianco/aries-cloudagent-python@endorser-write-did

demo/docker-agent/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Running an Author Agent and connecting to an Endorser
2+
3+
This directory contains scripts to run an aca-py agent as an Author, that can conenct to an Endorser service.
4+
5+
## Running the Author Agent
6+
7+
The docker-compose script runs ngrok to expose the agent's port publicly, and stores wallet data in a postgres database.
8+
9+
To run the Author agent in this repo, open a command shell in this directory and run:
10+
11+
- to build the containers:
12+
13+
```bash
14+
docker-compose build
15+
```
16+
17+
- to run the author agent:
18+
19+
```bash
20+
docker-compose up
21+
```
22+
23+
You can connect to the [agent's api service here](http://localhost:8010).
24+
25+
Note that all the configuration settings are hard-coded in the docker-compose file and ngrok-wait.sh script, so if you change any configs you need to rebuild the docker images.
26+
27+
- to shut down the agent:
28+
29+
```bash
30+
docker-compose stop
31+
docker-compose rm -f
32+
```
33+
34+
This will leave the agent's wallet data, so if you restart the agent it will maintain any created data.
35+
36+
- to remove the agent's wallet:
37+
38+
```bash
39+
docker volume rm docker-agent_wallet-db-data
40+
```
41+
42+
Note that the Author agent is not (yet) configured with revocations enabled or a tails server, so revocation is not supported.
43+
44+
## Connecting to an Endorser Service
45+
46+
For this example, we will connect to [this endorser service](https://github.com/bcgov/aries-endorser-service), which you can connect to locally at `http://localhost:5050/endorser/docs`.
47+
48+
Make sure you start the endorser service on the same ledger as your author, and make sure the endorser has a public DID with ENDORSER role.
49+
50+
For example start the endorser service as `LEDGER_URL=http://test.bcovrin.vonx.io TAILS_SERVER_URL=https://tails-test.vonx.io ./manage start --logs` and then make sure the Author agent is started with `--genesis_url http://test.bcovrin.vonx.io/genesis`.
51+
52+
### Connecting the Author to the Endorser
53+
54+
Endorser Service: Use the `GET /v1/admin/config` endpoint to fetch the endorser's configuration, including the public DID (which the author will need to know). Also confirm whether the `ENDORSER_AUTO_ACCEPT_CONNECTIONS` and `ENDORSER_AUTO_ENDORSE_REQUESTS` settings are `True` or `False` - for the following we will assume that both are `False` and the endorser must explicitely respond to all requests.
55+
56+
Author Agent: Use the `POST /didexchange/create-request` to request a connection with the endorser, using the endorser's public DID. Set the `alias` to `Endorser` - this *MUST* match the `--endorser-alias 'Endorser'` setting (in the ngrok-wait.sh script). Use the `GET /connections` endpoint to verify the connection is in `request` state.
57+
58+
Endorser Service: Use the `GET /v1/connections` endpoint to see the connection request (state `request`). Using the `connection_id`, call the `POST /connections/{connection_id}/accept` endpoint to accept the request. Verify that the connection state goes to `active`.
59+
60+
Author Agent: Verify the connection state goes to `active`. Use the `POST /transactions/{conn_id}/set-endorser-role` to set the connection role to `TRANSACTION_AUTHOR`, and then use `POST /transactions/{conn_id}/set-endorser-info` to set the endorser's alias to `Endorser` and the public DID to the endorser's public DID. Verify the settings using the `GET /connections/{conn_id}/meta-data` endpoint.
61+
62+
The connection is now setup between the two agents!
63+
64+
### Creating a Public Author DID
65+
66+
Author Agent: Use the `POST /wallet/did/create` (use an empty `{}` POST body) to create a local did. Then use `POST /ledger/register-nym` to send the data to the ledger - this will create a transaction and send it to the endorser service.
67+
68+
Endorser Service: Use the `GET /v1/endorse/transactions` endpoint to see the endorse request - it should be in state `request_received`. Using the `POST /v1/endorse/transactions/{transaction_id}/endorse` endpoint and the `transaction_id`, approve the request. The state should now (eventually) go to `transaction_acked`.
69+
70+
Author Service: Use the `GET /transactions` endpoint to verify the transaction is in `transaction_acked` state. Then use the `POST /wallet/did/public` to set the new DID to be the Author's public DID. This will generate another endorser transaction to set the DID's endpoint (ATTRIB transaction) on the ledger.
71+
72+
Endorser Service: Use the same endpoints as above (`GET /v1/endorse/transactions` and then `POST /v1/endorse/transactions/{transaction_id}/endorse`) to view the endorse request and approve it.
73+
74+
### Endorsing Author Requests
75+
76+
Author requests to create schema, create credential definition and create revocation registries will all now generate endorse requests to the endorser.
77+
78+
Author Agent: To create a schema use the `POST /schemas` endpoint. This will create an endorse request.
79+
80+
Endorser Service: Use the same endpoints as above (`GET /v1/endorse/transactions` and then `POST /v1/endorse/transactions/{transaction_id}/endorse`) to view the endorse request and approve it.
81+
82+
Author Agent: To create a cred def use the `POST /credential-definitions` endpoint. This will create an endorse request.
83+
84+
Endorser Service: Use the same endpoints as above (`GET /v1/endorse/transactions` and then `POST /v1/endorse/transactions/{transaction_id}/endorse`) to view the endorse request and approve it.
85+
86+
87+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Sample docker-compose to start a local aca-py author agent
2+
# To start aca-py and the postgres database, just run `docker-compose up`
3+
# To shut down the services run `docker-compose rm` - this will retain the postgres database, so you can change aca-py startup parameters
4+
# and restart the docker containers without losing your wallet data
5+
# If you want to delete your wallet data just run `docker volume ls -q | xargs docker volume rm`
6+
version: "3"
7+
services:
8+
ngrok-agent:
9+
image: wernight/ngrok
10+
ports:
11+
- 4067:4040
12+
command: ngrok http author-agent:8001 --log stdout
13+
14+
author-agent:
15+
build:
16+
context: .
17+
dockerfile: Dockerfile.acapy
18+
environment:
19+
- NGROK_NAME=ngrok-agent
20+
ports:
21+
- 8010:8010
22+
- 8001:8001
23+
depends_on:
24+
- wallet-db
25+
entrypoint: /bin/bash
26+
command: [
27+
"-c",
28+
"sleep 5; \
29+
./ngrok-wait.sh"
30+
]
31+
volumes:
32+
- ./ngrok-wait.sh:/home/indy/ngrok-wait.sh
33+
34+
wallet-db:
35+
image: vcr-postgresql
36+
environment:
37+
- POSTGRESQL_USER=DB_USER
38+
- POSTGRESQL_PASSWORD=DB_PASSWORD
39+
- POSTGRESQL_DATABASE=DB_USER
40+
- POSTGRESQL_ADMIN_PASSWORD=mysecretpassword
41+
ports:
42+
- 5433:5432
43+
volumes:
44+
- wallet-db-data:/var/lib/pgsql/data
45+
46+
volumes:
47+
wallet-db-data:

demo/docker-agent/ngrok-wait.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# based on code developed by Sovrin: https://github.com/hyperledger/aries-acapy-plugin-toolbox
4+
5+
echo "using ngrok end point [$NGROK_NAME]"
6+
7+
NGROK_ENDPOINT=null
8+
while [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]
9+
do
10+
echo "Fetching end point from ngrok service"
11+
NGROK_ENDPOINT=$(curl --silent $NGROK_NAME:4040/api/tunnels | ./jq -r '.tunnels[] | select(.proto=="https") | .public_url')
12+
13+
if [ -z "$NGROK_ENDPOINT" ] || [ "$NGROK_ENDPOINT" = "null" ]; then
14+
echo "ngrok not ready, sleeping 5 seconds...."
15+
sleep 5
16+
fi
17+
done
18+
19+
export ACAPY_ENDPOINT=$NGROK_ENDPOINT
20+
21+
echo "Starting aca-py agent with endpoint [$ACAPY_ENDPOINT]"
22+
23+
# ... if you want to echo the aca-py startup command ...
24+
set -x
25+
26+
exec aca-py start \
27+
--auto-provision \
28+
--inbound-transport http '0.0.0.0' 8001 \
29+
--outbound-transport http \
30+
--genesis-url "http://test.bcovrin.vonx.io/genesis" \
31+
--endpoint "${ACAPY_ENDPOINT}" \
32+
--auto-ping-connection \
33+
--monitor-ping \
34+
--public-invites \
35+
--wallet-type "indy" \
36+
--wallet-name "test_author" \
37+
--wallet-key "secret_key" \
38+
--wallet-storage-type "postgres_storage" \
39+
--wallet-storage-config "{\"url\":\"wallet-db:5432\",\"max_connections\":5}" \
40+
--wallet-storage-creds "{\"account\":\"DB_USER\",\"password\":\"DB_PASSWORD\",\"admin_account\":\"postgres\",\"admin_password\":\"mysecretpassword\"}" \
41+
--admin '0.0.0.0' 8010 \
42+
--label "test_author" \
43+
--admin-insecure-mode \
44+
--endorser-protocol-role author \
45+
--endorser-alias 'Endorser' \
46+
--auto-request-endorsement \
47+
--auto-write-transactions \
48+
--auto-create-revocation-transactions \
49+
--log-level "error"
50+
51+
# --genesis-url "https://raw.githubusercontent.com/ICCS-ISAC/dtrust-reconu/main/CANdy/dev/pool_transactions_genesis" \

demo/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asyncpg~=0.25.0
22
prompt_toolkit~=2.0.9
3-
git+https://github.com/webpy/webpy.git#egg=web.py
3+
web.py~=0.62
44
pygments~=2.10
55
qrcode[pil]~=6.1

0 commit comments

Comments
 (0)