Skip to content

Commit

Permalink
verifier returns creds json on successful verification (#38)
Browse files Browse the repository at this point in the history
* verifier returns creds json on successful verification

Signed-off-by: 2byrds <2byrds@gmail.com>

---------

Signed-off-by: 2byrds <2byrds@gmail.com>
  • Loading branch information
2byrds authored Sep 5, 2024
1 parent f0ee6c8 commit 3f66ee9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
23 changes: 15 additions & 8 deletions src/verifier/core/verifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import falcon
from keri.core import coring, parsing
from keri.vdr import verifying, eventing
from verifier.core.authorizing import Schema


def setup(app, hby, vdb, reger, local=False):
Expand Down Expand Up @@ -118,33 +119,39 @@ def on_put(self, req, rep, said):
vry=self.vry)

found = False
saids = []
while self.vry.cues:
msg = self.vry.cues.popleft()
if "creder" in msg:
creder = msg["creder"]
if creder.said == said:
found = True
break

if not found:
if not found:
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


saider = coring.Saider(qb64=said)
cred_attrs = creder.sad['a']
creds = None
if 'i' in cred_attrs:
saids = self.vry.reger.subjs.get(keys=cred_attrs['i'])
creds = self.vry.reger.cloneCreds(saids, self.hby.db)
else:
creds = self.vry.reger.cloneCreds((saider,), self.hby.db)

print(f"Credential {said} presented.")

saider = coring.Saider(qb64=said)
now = coring.Dater()

self.vdb.iss.pin(keys=(saider.qb64,), val=now)

rep.status = falcon.HTTP_ACCEPTED
rep.data = json.dumps(
dict(msg=f"{said} is a valid credential ", lei=creder.sad['a'].get('LEI'), aid=creder.sad['a'].get('i'))).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


class AuthorizationResourceEnd:
""" Authroization resource endpoint
Expand Down
9 changes: 2 additions & 7 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@

from .conftest import *

from hio.core import http
from keri.app import habbing, grouping, signing
from keri.app import signing
from keri.core import coring, eventing, parsing, scheming, serdering
from keri.db import basing
from keri.end import ending
from keri.help import helping
from keri import help, kering
from keri.peer import exchanging
from keri import kering
from keri.vdr import credentialing, verifying, viring
from keri.vdr.credentialing import Credentialer, proving

Expand Down

0 comments on commit 3f66ee9

Please sign in to comment.