From 456f28360b98e79570b4ebd42142e240a384ca61 Mon Sep 17 00:00:00 2001 From: Omer Shafiq Date: Fri, 10 Jul 2020 01:31:58 +0300 Subject: [PATCH] agency stable code --- README.md | 4 ++++ aries_cloudagency/admin/server.py | 2 ++ aries_cloudagency/agency/wallet.py | 15 +++++++++------ aries_cloudagency/transport/pack_format.py | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 868f888..bcf26c2 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ The administrative API exposed by the agent for the controller to use must be pr `--admin-insecure-mode` command line arg. The latter should not be used other than in development if the API is not otherwise secured. + +> Storage and some other modules were modified in aca-py to create this multi-tenant agency. This particular code base requires security and storage improvements! + + ## API Follows same api as ACA-PY with additional parameters in header see 'Usage' section. diff --git a/aries_cloudagency/admin/server.py b/aries_cloudagency/admin/server.py index cc0930d..0a7bc2b 100644 --- a/aries_cloudagency/admin/server.py +++ b/aries_cloudagency/admin/server.py @@ -237,6 +237,8 @@ async def agency_middleware(request, handler): self.context.injector.clear_binding(BaseStorage) wallet_instance: BaseWallet = await agency_wallet.get(wallet_name, wallet_key) + if wallet_instance is None: + raise web.HTTPUnauthorized() self.context.injector.bind_instance(BaseWallet, wallet_instance) storage = IndyStorage(wallet_instance) diff --git a/aries_cloudagency/agency/wallet.py b/aries_cloudagency/agency/wallet.py index 98e8920..97f4329 100644 --- a/aries_cloudagency/agency/wallet.py +++ b/aries_cloudagency/agency/wallet.py @@ -50,10 +50,13 @@ async def close(name, key): async def get(name, key): - wlt = open_wallets.get(name) - if wlt: - # print("Wallet already exist!") - return wlt + agency_storage = AgencyStorage() + wallet_info = await agency_storage.get_wallet(name, key) + if wallet_info is not None: + wlt = open_wallets.get(name) + if wlt: + return wlt + else: + return await open(name, key) else: - # print("Opening new wallet!") - return await open(name, key) + return None diff --git a/aries_cloudagency/transport/pack_format.py b/aries_cloudagency/transport/pack_format.py index db334ac..567bd69 100644 --- a/aries_cloudagency/transport/pack_format.py +++ b/aries_cloudagency/transport/pack_format.py @@ -131,6 +131,8 @@ async def unpack( context.injector.clear_binding(BaseStorage) wallet_instance: BaseWallet = await agency_wallet.get(recipient_wallet_name, wallet_info['wallet_secret']) + if wallet_instance is None: + raise MessageParseError("Wallet doesn't exist in agency!") context.injector.bind_instance(BaseWallet, wallet_instance) storage = IndyStorage(wallet_instance)