Skip to content

Commit 4a2b2d6

Browse files
fix: cherry-pick fixes from main to 1.2.lts (#3577)
* fix: connection reuse with multi-tenancy Signed-off-by: Daniel Bluhm <[email protected]> * Fixing tenant endpoint access Signed-off-by: Thiago Romano <[email protected]> * Fixing failed test Signed-off-by: Thiago Romano <[email protected]> --------- Signed-off-by: Daniel Bluhm <[email protected]> Signed-off-by: Thiago Romano <[email protected]> Co-authored-by: Daniel Bluhm <[email protected]>
1 parent 509bfab commit 4a2b2d6

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

acapy_agent/admin/decorators/auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def tenant_auth(request):
7878
(multitenant_enabled and authorization_header)
7979
or (not multitenant_enabled and valid_key)
8080
or (multitenant_enabled and valid_key and base_wallet_allowed_route)
81-
or insecure_mode
81+
or (insecure_mode and not multitenant_enabled)
8282
or request.method == "OPTIONS"
8383
):
8484
return await handler(request)

acapy_agent/admin/tests/test_auth.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ async def test_options_request(self):
8686
await decor_func(self.request)
8787
self.decorated_handler.assert_called_once_with(self.request)
8888

89-
async def test_insecure_mode(self):
89+
async def test_insecure_mode_witout_token(self):
9090
self.profile.settings["admin.admin_insecure_mode"] = True
9191
decor_func = tenant_authentication(self.decorated_handler)
92-
await decor_func(self.request)
93-
self.decorated_handler.assert_called_once_with(self.request)
92+
with self.assertRaises(web.HTTPUnauthorized):
93+
await decor_func(self.request)
9494

9595
async def test_single_tenant_invalid_api_key(self):
9696
self.profile.settings["multitenant.enabled"] = False

acapy_agent/core/profile.py

+15
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ def __repr__(self) -> str:
130130
self.__class__.__name__, self.backend, self.name
131131
)
132132

133+
def __eq__(self, other) -> bool:
134+
"""Equality checks for profiles.
135+
136+
Multiple profile instances can exist at the same time but point to the
137+
same profile. This allows us to test equality based on the profile
138+
pointed to by the instance rather than by object reference comparison.
139+
"""
140+
if not isinstance(other, Profile):
141+
return False
142+
143+
if type(self) is not type(other):
144+
return False
145+
146+
return self.name == other.name
147+
133148

134149
class ProfileManager(ABC):
135150
"""Handle provision and open for profile instances."""

acapy_agent/protocols/out_of_band/v1_0/routes.py

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ async def invitation_receive(request: web.BaseRequest):
328328
mediation_id=mediation_id,
329329
)
330330
except (DIDXManagerError, StorageError, BaseModelError) as err:
331+
LOGGER.exception("Error during receive invitation")
331332
raise web.HTTPBadRequest(reason=err.roll_up) from err
332333

333334
return web.json_response(result.serialize())

0 commit comments

Comments
 (0)