Skip to content

Commit

Permalink
properly return the ecr cred
Browse files Browse the repository at this point in the history
Signed-off-by: 2byrds <2byrds@gmail.com>
  • Loading branch information
2byrds committed Sep 5, 2024
1 parent b89553e commit 4e91958
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/verifier/core/verifying.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,35 +119,37 @@ def on_put(self, req, rep, said):
vry=self.vry)

found = False
creds = None
saids = []
while self.vry.cues:
msg = self.vry.cues.popleft()
if "creder" in msg:
creder = msg["creder"]
if creder.said == said:
found = True
saider = coring.Saider(qb64=said)
cred_attrs = creder.sad['a']
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.")

now = coring.Dater()
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.")

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

rep.status = falcon.HTTP_ACCEPTED
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
self.vdb.iss.pin(keys=(saider.qb64,), val=now)

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")
rep.status = falcon.HTTP_ACCEPTED
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:
Expand Down

0 comments on commit 4e91958

Please sign in to comment.