Skip to content

Commit

Permalink
Merge branch 'main' into creds_json
Browse files Browse the repository at this point in the history
  • Loading branch information
2byrds authored Sep 4, 2024
2 parents fe8c4be + f0ee6c8 commit 74932a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion images/verifier.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ WORKDIR /usr/local/var/vlei-verifier/

RUN pip install -r requirements.txt

ENTRYPOINT ["verifier", "server", "start", "--config-dir", "scripts", "--config-file", "verifier-config-rootsid.json"]
ENTRYPOINT ["verifier", "server", "start", "--config-dir", "scripts", "--config-file", "verifier-config-public.json"]
31 changes: 19 additions & 12 deletions src/verifier/core/verifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from keri.vdr import verifying, eventing
from verifier.core.authorizing import Schema


def setup(app, hby, vdb, reger, local=False):
""" Set up verifying endpoints to process vLEI credential verifications
Expand Down Expand Up @@ -104,13 +105,14 @@ def on_put(self, req, rep, said):

if req.content_type not in ("application/json+cesr",):
rep.status = falcon.HTTP_BAD_REQUEST
rep.data = json.dumps(dict(msg=f"invalid content type={req.content_type} for VC presentation")).encode("utf-8")
rep.data = json.dumps(dict(msg=f"invalid content type={req.content_type} for VC presentation")).encode(
"utf-8")
return

ims = req.bounded_stream.read()

self.vry.cues.clear()

parsing.Parser().parse(ims=ims,
kvy=self.hby.kvy,
tvy=self.tvy,
Expand Down Expand Up @@ -140,15 +142,15 @@ def on_put(self, req, rep, said):
self.vdb.iss.pin(keys=(saider.qb64,), val=now)

rep.status = falcon.HTTP_ACCEPTED
rep.data = json.dumps(dict(creds=json.dumps(creds),msg=f"{said} is a valid credential ")).encode("utf-8")
rep.data = json.dumps(dict(creds=json.dumps(creds), msg=f"{said} is a valid credential ",
lei=creder.sad['a'].get('LEI'), aid=creder.sad['a'].get('i')))
.encode("utf-8")
return

rep.status = falcon.HTTP_BAD_REQUEST
rep.data = json.dumps(dict(msg=f"credential {said} from body of request did not verify")).encode("utf-8")
return



class AuthorizationResourceEnd:
""" Authroization resource endpoint
Expand Down Expand Up @@ -196,7 +198,7 @@ def on_get(self, req, rep, aid):
"""
rep.content_type = "application/json"

if aid not in self.hby.kevers:
rep.status = falcon.HTTP_UNAUTHORIZED
rep.data = json.dumps(dict(msg=f"unknown AID: {aid}")).encode("utf-8")
Expand All @@ -217,6 +219,7 @@ def on_get(self, req, rep, aid):
rep.data = json.dumps(body).encode("utf-8")
return


class RequestVerifierResourceEnd:
""" Request Verifier Resource endpoint class
Expand Down Expand Up @@ -267,15 +270,15 @@ def on_post(self, req, rep, aid):
"""
rep.content_type = "application/json"

data = req.params.get("data")
if data is None:
rep.status = falcon.HTTP_BAD_REQUEST
rep.data = json.dumps(dict(msg="request missing data parameter")).encode("utf-8")
return

encoded_data = data.encode("utf-8") #signature is based on encoded data
encoded_data = data.encode("utf-8") # signature is based on encoded data

sign = req.params.get("sig")
if sign is None:
rep.status = falcon.HTTP_BAD_REQUEST
Expand All @@ -298,23 +301,27 @@ def on_post(self, req, rep, aid):
cigar = coring.Cigar(qb64=sign)
except Exception as ex:
rep.status = falcon.HTTP_BAD_REQUEST
rep.data = json.dumps(dict(msg=f"{aid} provided invalid Cigar signature on encoded request data")).encode("utf-8")
rep.data = json.dumps(dict(msg=f"{aid} provided invalid Cigar signature on encoded request data")).encode(
"utf-8")
return

if not verfers[0].verify(sig=cigar.raw, ser=encoded_data):
rep.status = falcon.HTTP_UNAUTHORIZED
rep.data = json.dumps(dict(msg=f"{aid} signature (Cigar) verification failed on encoding of request data")).encode("utf-8")
rep.data = json.dumps(
dict(msg=f"{aid} signature (Cigar) verification failed on encoding of request data")).encode("utf-8")
return

rep.status = falcon.HTTP_ACCEPTED
rep.data = json.dumps(dict(msg="Signature Valid")).encode("utf-8")
return


class HealthEndpoint:
def __init__(self):
pass

def on_get(self, req, rep):
rep.content_type = "application/json"
rep.status = falcon.HTTP_OK
rep.data = json.dumps(dict(msg="vLEI verification service is healthy")).encode("utf-8")
return
return

0 comments on commit 74932a8

Please sign in to comment.