Skip to content

Commit 7ebed18

Browse files
authored
Merge pull request #70 from didx-xyz/issue_61
Major refactor of tutorial folder structure.
2 parents 031713c + 5b60f4b commit 7ebed18

File tree

68 files changed

+3379
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3379
-393
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# see: https://pypi.org/project/ConfigArgParse/ for file format overview
2+
# before running aca-py, run the following (the commands are embedded below, next to the related parameters):
3+
# - run a local postgres database
4+
# - run a local instance of von-network
5+
# - register your did (seed) on the network
6+
# run aca-py as:
7+
# ACAPY_WALLET_SEED=my_seed_000000000000000000000000 ACAPY_WALLET_KEY=key ./bin/aca-py start --arg-file ./demo/local-indy-args.yaml
8+
9+
log-level: info
10+
genesis-url: !ENV ${GENESIS_URL}
11+
# Admin insecure mode and api key will come from the following two variables
12+
# which is parsed and used automatically by ACA-Py
13+
# ACAPY_ADMIN_API_KEY
14+
# ACAPY_ADMIN_INSECURE_MODE
15+
admin: [0.0.0.0, !ENV '${ADMIN_PORT}']
16+
label: !ENV ${AGENT_NAME}
17+
# the following is the callback url for your controller
18+
webhook-url: !ENV ${WEBHOOK_URL}
19+
# assumes you are running a local von-network, like:
20+
# cd von-network
21+
# ./manage start <my local ip>
22+
inbound-transport:
23+
- [http, 0.0.0.0, !ENV '${HTTP_PORT}']
24+
# - [ws, 0.0.0.0, !ENV '${HTTP_PORT}']
25+
outbound-transport: http
26+
# the following is the public endpoint advertised by the agent
27+
endpoint: !ENV ${AGENT_ENDPOINT}
28+
auto-ping-connection: true
29+
# register your did using (this example is for von-network):
30+
# curl -d '{"seed":"my_seed_000000000000000000000000", "role":"TRUST_ANCHOR", "alias":"My Agent"}' -X POST http://localhost:9000/register
31+
# note that the env var name is configured in argparse.py
32+
# seed = comes from ACAPY_WALLET_SEED
33+
wallet-type: !ENV ${WALLET_TYPE}
34+
wallet-name: !ENV ${WALLET_NAME}
35+
wallet-key: !ENV ${WALLET_KEY}
36+
seed: !ENV ${WALLET_SEED}
37+
38+
## run a local postgres (docker) like:
39+
## docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres:10
40+
#wallet-storage-type: postgres_storage
41+
## could be sent using env var ACAPY_WALLET_STORAGE_CONFIG
42+
#wallet-storage-config: '{"url":"localhost:5432","max_connections":5}'
43+
## could be sent using env var ACAPY_WALLET_STORAGE_CREDS
44+
#wallet-storage-creds: '{"account":"postgres","password":"mysecretpassword","admin_account":"postgres","admin_password":"mysecretpassword"}'
45+
46+
47+
auto-accept-requests: true
48+
auto-provision: true
49+
auto-respond-credential-proposal: false
50+
auto-respond-credential-offer: false
51+
auto-respond-credential-request: false
52+
auto-store-credential: false
53+
auto-respond-presentation-proposal: true
54+
auto-respond-presentation-request: true
55+
preserve-exchange-records: true
56+
debug-connections: true
57+
debug-credentials: true
58+
debug-presentations: true
59+
enable-undelivered-queue: true
60+
open-mediation: true

dockerfiles/controllers/Dockerfile.attachmentcontroller

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ARG jupyter_port
66
ENV env_jupyter_port=jupyter_port
77
# Setup workspace environment
88
RUN apt-get update && apt-get install -y gcc
9-
# RUN conda install jupyter notebook=5.7.8
10-
RUN conda install jupyter notebook=6.1.5
9+
# RUN conda install -c conda-forge jupyterlab==3.0.11
10+
RUN conda install -c conda-forge jupyterlab==3.0.11
1111

1212
ADD libs/attachment-controller attachment-controller
1313

dockerfiles/controllers/Dockerfile.basiccontroller

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ENV env_jupyter_port=jupyter_port
77

88
# Setup workspace environment
99
RUN apt-get update && apt-get install -y gcc
10-
# RUN conda install jupyter notebook=5.7.8
11-
RUN conda install jupyter notebook=6.1.5
10+
# RUN conda install -c conda-forge jupyterlab==3.0.11
11+
RUN conda install -c conda-forge jupyterlab==3.0.11
1212
ADD libs/aries-basic-controller .
1313

1414
#

libs/acapy-protocol-example/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ fi
1010

1111
cd $WORKSPACE
1212
echo "HELLO THIS IS PORT $1"
13-
jupyter notebook --ip=0.0.0.0 --port="$1" --allow-root
13+
jupyter lab --ip=0.0.0.0 --port="$1" --allow-root

libs/aries-basic-controller/aries_basic_controller/aries_controller.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
from .controllers.connections import ConnectionsController
99
from .controllers.messaging import MessagingController
10+
from .controllers.mediation import MediationController
1011
from .controllers.schema import SchemaController
1112
from .controllers.wallet import WalletController
1213
from .controllers.definitions import DefinitionsController
1314
from .controllers.issuer import IssuerController
1415
from .controllers.proof import ProofController
1516
from .controllers.ledger import LedgerController
1617
from .controllers.credential import CredentialController
18+
from .controllers.multitenant import MultitenancyController
1719
from .controllers.server import ServerController
1820
from .controllers.oob import OOBController
1921
from .controllers.action_menu import ActionMenuController
@@ -35,10 +37,13 @@ def __init__(
3537
webhook_base: str = "",
3638
connections: bool = True,
3739
messaging: bool = True,
40+
multitenant: bool = False,
41+
mediation: bool = False,
3842
issuer: bool = True,
3943
action_menu: bool = True,
4044
revocations: bool = True,
4145
api_key: str = None,
46+
tennant_jwt: str = None,
4247
):
4348

4449
self.webhook_site = None
@@ -51,11 +56,16 @@ def __init__(
5156
self.webhook_port = webhook_port
5257
self.connections_controller = None
5358

59+
headers = {}
60+
5461
if api_key:
55-
headers = {"X-API-Key": api_key}
56-
self.client_session: ClientSession = ClientSession(headers=headers)
57-
else:
58-
self.client_session: ClientSession = ClientSession()
62+
headers.update({"X-API-Key": api_key})
63+
64+
if tennant_jwt:
65+
headers.update({'Authorization': 'Bearer ' + tennant_jwt, 'content-type': "application/json"})
66+
67+
self.client_session: ClientSession = ClientSession(headers=headers)
68+
5969

6070
if connections:
6171
self.connections = ConnectionsController(self.admin_url, self.client_session)
@@ -68,6 +78,12 @@ def __init__(
6878
self.server = ServerController(self.admin_url, self.client_session)
6979
self.oob = OOBController(self.admin_url, self.client_session)
7080

81+
if multitenant:
82+
self.multitenant = MultitenancyController(self.admin_url, self.client_session)
83+
84+
if mediation:
85+
self.mediation = MediationController(self.admin_url, self.client_session)
86+
7187
if issuer:
7288
self.schema = SchemaController(self.admin_url, self.client_session)
7389
self.wallet = WalletController(self.admin_url, self.client_session)
@@ -77,12 +93,55 @@ def __init__(
7793

7894
if action_menu:
7995
self.action_menu = ActionMenuController(self.admin_url, self.client_session)
96+
8097
if revocations:
8198
self.revocations = RevocationController(
8299
self.admin_url,
83100
self.client_session
84101
)
85102

103+
# TODO: Determine whether we really want to essentially create a whole new ClientSession object as done below
104+
# Ideally we'd just update the existing session along the lines of self.client_session(headers)
105+
# That does not work, though because it is not callable and updating cannot be achieved reliably
106+
# because headers can be of different type
107+
# from https://docs.aiohttp.org/en/stable/client_reference.html :
108+
# "May be either iterable of key-value pairs or Mapping (e.g. dict, CIMultiDict)."
109+
# So for now let's create a new ClientSession and use all the instances current attributes
110+
# to update every attr using ClientSession
111+
def update_tennant_jwt(self, tennant_jwt):
112+
self.tennant_jwt = tennant_jwt
113+
headers = {'Authorization': 'Bearer ' + tennant_jwt, 'content-type': "application/json"}
114+
self.client_session: ClientSession = ClientSession(headers=headers)
115+
116+
if self.connections:
117+
self.connections = ConnectionsController(self.admin_url, self.client_session)
118+
119+
if self.messaging:
120+
self.messaging = MessagingController(self.admin_url, self.client_session)
121+
122+
if self.multitenant:
123+
self.multitenant = MultitenancyController(self.admin_url, self.client_session)
124+
125+
if self.mediation:
126+
self.mediation = MediationController(self.admin_url, self.client_session)
127+
128+
if self.issuer:
129+
self.schema = SchemaController(self.admin_url, self.client_session)
130+
self.wallet = WalletController(self.admin_url, self.client_session)
131+
self.definitions = DefinitionsController(self.admin_url, self.client_session)
132+
self.issuer = IssuerController(self.admin_url, self.client_session, self.connections,
133+
self.wallet, self.definitions)
134+
135+
if self.action_menu:
136+
self.action_menu = ActionMenuController(self.admin_url, self.client_session)
137+
138+
if self.revocations:
139+
self.revocations = RevocationController(
140+
self.admin_url,
141+
self.client_session
142+
)
143+
144+
86145
def register_listeners(self, listeners, defaults=True):
87146
if defaults:
88147
if self.connections:

libs/aries-basic-controller/aries_basic_controller/controllers/mediation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def default_handler(self, payload):
2020

2121
# Get default mediator
2222
async def get_default_mediator(self):
23-
return await self.admin_POST(f"{self.base_url}/default-mediator")
23+
return await self.admin_GET(f"{self.base_url}/default-mediator")
2424

2525

2626
# Clear default mediator
@@ -57,12 +57,12 @@ async def send_keylist_update(self, request, mediation_id: str):
5757

5858

5959
# Request mediation from connection
60-
async def request_mediation(self, request, conn_id: str):
60+
async def request_mediation(self, conn_id: str, request: {} = {}):
6161
return await self.admin_POST(f"{self.base_url}/request/{conn_id}", json_data=request)
6262

6363

6464
# Query mediation requests, returns list of all mediation records
65-
async def get_mediation_records(self, mediator_terms: [str], recipient_terms: [str], state: str = None, conn_id: str = None):
65+
async def get_mediation_records(self, mediator_terms: [str] = None, recipient_terms: [str] = None, state: str = None, conn_id: str = None):
6666
params = {}
6767
if conn_id:
6868
params["conn_id"] = conn_id
@@ -96,6 +96,6 @@ async def grant_mediation_request_by_id(self, mediation_id: str):
9696
return await self.admin_POST(f"{self.base_url}/requests/{mediation_id}/grant")
9797

9898

99-
# Grant received mediation request
99+
# Set default mediator
100100
async def set_default_mediator(self, mediation_id: str):
101-
return await self.admin_PUT(f"{self.base_url}/requests/{mediation_id}/default-mediator")
101+
return await self.admin_PUT(f"{self.base_url}/{mediation_id}/default-mediator")

libs/aries-basic-controller/aries_basic_controller/controllers/multitenant.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ async def update_subwallet_by_id(self, request, wallet_id: str):
3434

3535

3636
# Remove a subwallet
37-
async def remove_subwallet_by_id(self, request, wallet_id: str):
37+
async def remove_subwallet_by_id(self, wallet_id: str, request=None):
3838
return await self.admin_POST(f"{self.base_url}/wallet/{wallet_id}/remove", json_data=request)
3939

4040

4141
# Get auth token for a subwallet
42-
async def get_subwallet_authtoken_by_id(self, request, wallet_id: str):
42+
async def get_subwallet_authtoken_by_id(self, wallet_id: str, request=None):
4343
return await self.admin_POST(f"{self.base_url}/wallet/{wallet_id}/token", json_data=request)
4444

4545

libs/aries-basic-controller/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp~=3.6.2
1+
aiohttp~=3.7.3
22
asyncio
33
prompt_toolkit
44
pygments

projects/aries-fl/Dockerfile.hospitalcontroller

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ENV env_jupyter_port=jupyter_port
77

88
# Setup workspace environment
99
RUN apt-get update && apt-get install -y gcc
10-
# RUN conda install jupyter notebook=5.7.8
11-
RUN conda install jupyter notebook=6.1.5
10+
# RUN conda install -c conda-forge jupyterlab==3.0.11
11+
RUN conda install -c conda-forge jupyterlab==3.0.11
1212

1313

1414
ADD projects/aries-fl/requirements.txt .

projects/aries-fl/Dockerfile.ppmlcontroller

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ ENV env_jupyter_port=jupyter_port
77

88
# Setup workspace environment
99
RUN apt-get update && apt-get install -y gcc
10-
# RUN conda install jupyter notebook=5.7.8
11-
RUN conda install jupyter notebook=6.1.5
10+
# RUN conda install -c conda-forge jupyterlab==3.0.11
11+
RUN conda install -c conda-forge jupyterlab==3.0.11
1212

1313

1414
ADD projects/aries-fl/requirements.txt .

0 commit comments

Comments
 (0)