diff --git a/aries_cloudagent/messaging/credential_definitions/routes.py b/aries_cloudagent/messaging/credential_definitions/routes.py index ccbf5cb660..31a07b9ae1 100644 --- a/aries_cloudagent/messaging/credential_definitions/routes.py +++ b/aries_cloudagent/messaging/credential_definitions/routes.py @@ -232,13 +232,13 @@ async def credential_definitions_send_credential_definition(request: web.BaseReq ) # check if we need to endorse - if is_author_role(context.profile): + if is_author_role(profile): # authors cannot write to the ledger write_ledger = False create_transaction_for_endorser = True if not connection_id: # author has not provided a connection id, so determine which to use - connection_id = await get_endorser_connection_id(context.profile) + connection_id = await get_endorser_connection_id(profile) if not connection_id: raise web.HTTPBadRequest(reason="No endorser connection found") @@ -317,7 +317,7 @@ async def credential_definitions_send_credential_definition(request: web.BaseReq if not create_transaction_for_endorser: # Notify event meta_data["processing"]["auto_create_rev_reg"] = True - await notify_cred_def_event(context.profile, cred_def_id, meta_data) + await notify_cred_def_event(profile, cred_def_id, meta_data) return web.json_response( { @@ -335,7 +335,7 @@ async def credential_definitions_send_credential_definition(request: web.BaseReq "endorser.auto_create_rev_reg" ) - transaction_mgr = TransactionManager(context.profile) + transaction_mgr = TransactionManager(profile) try: transaction = await transaction_mgr.create_record( messages_attach=cred_def["signed_txn"], @@ -417,15 +417,16 @@ async def credential_definitions_get_credential_definition(request: web.BaseRequ """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) cred_def_id = request.match_info["cred_def_id"] - async with context.profile.session() as session: + async with profile.session() as session: multitenant_mgr = session.inject_or(BaseMultitenantManager) if multitenant_mgr: - ledger_exec_inst = IndyLedgerRequestsExecutor(context.profile) + ledger_exec_inst = IndyLedgerRequestsExecutor(profile) else: ledger_exec_inst = session.inject(IndyLedgerRequestsExecutor) ledger_id, ledger = await ledger_exec_inst.get_ledger_for_identifier( @@ -466,16 +467,17 @@ async def credential_definitions_fix_cred_def_wallet_record(request: web.BaseReq """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) cred_def_id = request.match_info["cred_def_id"] - async with context.profile.session() as session: + async with profile.session() as session: storage = session.inject(BaseStorage) multitenant_mgr = session.inject_or(BaseMultitenantManager) if multitenant_mgr: - ledger_exec_inst = IndyLedgerRequestsExecutor(context.profile) + ledger_exec_inst = IndyLedgerRequestsExecutor(profile) else: ledger_exec_inst = session.inject(IndyLedgerRequestsExecutor) ledger_id, ledger = await ledger_exec_inst.get_ledger_for_identifier( diff --git a/aries_cloudagent/messaging/schemas/routes.py b/aries_cloudagent/messaging/schemas/routes.py index f745cc25b0..5ef8e0a0e8 100644 --- a/aries_cloudagent/messaging/schemas/routes.py +++ b/aries_cloudagent/messaging/schemas/routes.py @@ -380,15 +380,16 @@ async def schemas_get_schema(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) schema_id = request.match_info["schema_id"] - async with context.profile.session() as session: + async with profile.session() as session: multitenant_mgr = session.inject_or(BaseMultitenantManager) if multitenant_mgr: - ledger_exec_inst = IndyLedgerRequestsExecutor(context.profile) + ledger_exec_inst = IndyLedgerRequestsExecutor(profile) else: ledger_exec_inst = session.inject(IndyLedgerRequestsExecutor) ledger_id, ledger = await ledger_exec_inst.get_ledger_for_identifier( @@ -429,8 +430,8 @@ async def schemas_fix_schema_wallet_record(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] - profile = context.profile + is_anoncreds_profile_raise_web_exception(profile) schema_id = request.match_info["schema_id"] @@ -439,7 +440,7 @@ async def schemas_fix_schema_wallet_record(request: web.BaseRequest): storage = session.inject(BaseStorage) multitenant_mgr = session.inject_or(BaseMultitenantManager) if multitenant_mgr: - ledger_exec_inst = IndyLedgerRequestsExecutor(context.profile) + ledger_exec_inst = IndyLedgerRequestsExecutor(profile) else: ledger_exec_inst = session.inject(IndyLedgerRequestsExecutor) ledger_id, ledger = await ledger_exec_inst.get_ledger_for_identifier( diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index ecaf016438..c1f72768b5 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -698,13 +698,14 @@ async def clear_pending_revocations(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) body = await request.json() purge = body.get("purge") - rev_manager = RevocationManager(context.profile) + rev_manager = RevocationManager(profile) try: results = await rev_manager.clear_pending_revocations(purge) @@ -853,6 +854,7 @@ async def get_rev_reg(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] profile = context.profile + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] @@ -883,10 +885,13 @@ async def get_rev_reg_issued_count(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile + + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] - async with context.profile.session() as session: + async with profile.session() as session: try: await IssuerRevRegRecord.retrieve_by_revoc_reg_id(session, rev_reg_id) except StorageNotFoundError as err: @@ -915,13 +920,14 @@ async def get_rev_reg_issued(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] recs = [] - async with context.profile.session() as session: + async with profile.session() as session: try: await IssuerRevRegRecord.retrieve_by_revoc_reg_id(session, rev_reg_id) except StorageNotFoundError as err: @@ -951,12 +957,13 @@ async def get_rev_reg_indy_recs(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] - revoc = IndyRevocation(context.profile) + revoc = IndyRevocation(profile) rev_reg_delta = await revoc.get_issuer_rev_reg_delta(rev_reg_id) return web.json_response( @@ -984,8 +991,9 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] @@ -995,7 +1003,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest): rev_reg_record = None genesis_transactions = None - async with context.profile.session() as session: + async with profile.session() as session: try: rev_reg_record = await IssuerRevRegRecord.retrieve_by_revoc_reg_id( session, rev_reg_id @@ -1028,7 +1036,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest): reason += ": missing wallet-type?" raise web.HTTPInternalServerError(reason=reason) - rev_manager = RevocationManager(context.profile) + rev_manager = RevocationManager(profile) try: ( rev_reg_delta, @@ -1074,15 +1082,16 @@ async def get_cred_rev_record(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] + profile = context.profile - is_anoncreds_profile_raise_web_exception(context.profile) + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.query.get("rev_reg_id") cred_rev_id = request.query.get("cred_rev_id") # numeric string cred_ex_id = request.query.get("cred_ex_id") try: - async with context.profile.session() as session: + async with profile.session() as session: if rev_reg_id and cred_rev_id: rec = await IssuerCredRevRecord.retrieve_by_ids( session, rev_reg_id, cred_rev_id @@ -1148,6 +1157,7 @@ async def get_tails_file(request: web.BaseRequest) -> web.FileResponse: """ context: AdminRequestContext = request["context"] profile = context.profile + is_anoncreds_profile_raise_web_exception(profile) rev_reg_id = request.match_info["rev_reg_id"] diff --git a/aries_cloudagent/revocation_anoncreds/routes.py b/aries_cloudagent/revocation_anoncreds/routes.py index 80f0bb6c6b..cec9aa164a 100644 --- a/aries_cloudagent/revocation_anoncreds/routes.py +++ b/aries_cloudagent/revocation_anoncreds/routes.py @@ -515,6 +515,7 @@ async def revoke(request: web.BaseRequest): """ context: AdminRequestContext = request["context"] profile = context.profile + is_not_anoncreds_profile_raise_web_exception(profile) body = await request.json() @@ -951,7 +952,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest): reason += ": missing wallet-type?" raise web.HTTPInternalServerError(reason=reason) - rev_manager = RevocationManager(context.profile) + rev_manager = RevocationManager(profile) try: ( rev_reg_delta,