Skip to content

Commit 8abb3bd

Browse files
committed
Fix bug in authing to not chomp URLs for auth.
Add support for mailbox OOBI resolution. Signed-off-by: pfeairheller <pfeairheller@gmail.com>
1 parent e2a6b96 commit 8abb3bd

File tree

3 files changed

+48
-22
lines changed

3 files changed

+48
-22
lines changed

scripts/keri/cf/demo-witness-oobis.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"curls": ["http://127.0.0.1:3902/"]
66
},
77
"iurls": [
8-
"http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller",
9-
"http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller",
10-
"http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller"
8+
"http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller?name=Wan&tag=witness",
9+
"http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller?name=Wes&tag=witness",
10+
"http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller?name=Wil&tag=witness"
1111
]
1212
}

src/keria/app/aiding.py

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -664,24 +664,46 @@ def on_get(req, rep, name):
664664
elif role in (kering.Roles.agent,): # Fetch URL OOBIs for all witnesses
665665
roleUrls = hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.agent, scheme=kering.Schemes.http) or hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.agent, scheme=kering.Schemes.https)
666666
if kering.Roles.agent not in roleUrls:
667-
raise falcon.HTTPNotFound(description=f"unable to query agent roles for {hab.pre}, no http endpoint")
668-
669-
aoobis = roleUrls[kering.Roles.agent]
670-
671-
oobis = list()
672-
for agent in set(aoobis.keys()):
673-
murls = aoobis.naball(agent)
674-
for murl in murls:
675-
urls = []
676-
if kering.Schemes.http in murl:
677-
urls.extend(murl.naball(kering.Schemes.http))
678-
if kering.Schemes.https in murl:
679-
urls.extend(murl.naball(kering.Schemes.https))
680-
for url in urls:
681-
up = urlparse(url)
682-
oobis.append(urljoin(up.geturl(), f"/oobi/{hab.pre}/agent/{agent}"))
683-
684-
res["oobis"] = oobis
667+
res['oobis'] = []
668+
else:
669+
aoobis = roleUrls[kering.Roles.agent]
670+
671+
oobis = list()
672+
for agent in set(aoobis.keys()):
673+
murls = aoobis.naball(agent)
674+
for murl in murls:
675+
urls = []
676+
if kering.Schemes.http in murl:
677+
urls.extend(murl.naball(kering.Schemes.http))
678+
if kering.Schemes.https in murl:
679+
urls.extend(murl.naball(kering.Schemes.https))
680+
for url in urls:
681+
up = urlparse(url)
682+
oobis.append(urljoin(up.geturl(), f"/oobi/{hab.pre}/agent/{agent}"))
683+
684+
res["oobis"] = oobis
685+
elif role in (kering.Roles.mailbox,): # Fetch URL OOBIs for all witnesses
686+
roleUrls = (hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.mailbox, scheme=kering.Schemes.http) or
687+
hab.fetchRoleUrls(cid=hab.pre, role=kering.Roles.mailbox, scheme=kering.Schemes.https))
688+
if kering.Roles.mailbox not in roleUrls:
689+
res['oobis'] = []
690+
else:
691+
aoobis = roleUrls[kering.Roles.mailbox]
692+
693+
oobis = list()
694+
for mailbox in set(aoobis.keys()):
695+
murls = aoobis.naball(mailbox)
696+
for murl in murls:
697+
urls = []
698+
if kering.Schemes.http in murl:
699+
urls.extend(murl.naball(kering.Schemes.http))
700+
if kering.Schemes.https in murl:
701+
urls.extend(murl.naball(kering.Schemes.https))
702+
for url in urls:
703+
up = urlparse(url)
704+
oobis.append(urljoin(up.geturl(), f"/oobi/{hab.pre}/mailbox/{mailbox}"))
705+
706+
res["oobis"] = oobis
685707
else:
686708
raise falcon.HTTPBadRequest(description=f"unsupport role type {role} for oobi request")
687709

src/keria/core/authing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
keria.core.authing module
55
66
"""
7-
7+
from urllib.parse import quote, unquote
88
import falcon
99
from hio.help import Hict
1010
from keri import kering
@@ -167,9 +167,12 @@ def process_request(self, req, resp):
167167
if req.path.startswith(path):
168168
return
169169

170+
req.path = quote(req.path)
171+
170172
try:
171173
# Use Authenticater to verify the signature on the request
172174
if self.authn.verify(req):
175+
req.path = unquote(req.path)
173176
resource = self.authn.resource(req)
174177
agent = self.agency.get(caid=resource)
175178

@@ -198,6 +201,7 @@ def process_response(self, req, rep, resource, req_succeeded):
198201
"""
199202

200203
if hasattr(req.context, "agent"):
204+
req.path = quote(req.path)
201205
agent = req.context.agent
202206
rep.set_header('Signify-Resource', agent.agentHab.pre)
203207
rep.set_header('Signify-Timestamp', helping.nowIso8601())

0 commit comments

Comments
 (0)