Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact challenges missing from GET /contacts/{prefix} #173

Open
lenkan opened this issue Jan 22, 2024 · 1 comment
Open

Contact challenges missing from GET /contacts/{prefix} #173

lenkan opened this issue Jan 22, 2024 · 1 comment

Comments

@lenkan
Copy link
Collaborator

lenkan commented Jan 22, 2024

Currently, you can get challenge information for a contact using the list contacts endpoint (GET /contacts). It is added here:

keria/src/keria/app/aiding.py

Lines 1143 to 1167 in f24cf4b

self.authn(agent, data)
rep.status = falcon.HTTP_200
rep.data = json.dumps(data).encode("utf-8")
@staticmethod
def authn(agent, contacts):
for contact in contacts:
aid = contact['id']
accepted = [saider.qb64 for saider in agent.hby.db.chas.get(keys=(aid,))]
received = [saider.qb64 for saider in agent.hby.db.reps.get(keys=(aid,))]
challenges = []
for said in received:
exn = agent.hby.db.exns.get(keys=(said,))
challenges.append(dict(dt=exn.ked['dt'], words=exn.ked['a']['words'], said=said,
authenticated=said in accepted))
contact["challenges"] = challenges
wellKnowns = []
wkans = agent.hby.db.wkas.get(keys=(aid,))
for wkan in wkans:
wellKnowns.append(dict(url=wkan.url, dt=wkan.dt))
contact["wellKnowns"] = wellKnowns
, yielding an array response with the following shape:

  id: string;
  alias: string;
  oobi: string;
  challenges: Challenge[];

On the endpoint for getting a contact by id, this information is missing:

keria/src/keria/app/aiding.py

Lines 1294 to 1303 in f24cf4b

agent = req.context.agent
if prefix not in agent.hby.kevers:
raise falcon.HTTPNotFound(description=f"{prefix} is not a known identifier.")
contact = agent.org.get(prefix)
if contact is None:
raise falcon.HTTPNotFound(description="NOT FOUND")
rep.status = falcon.HTTP_200
rep.data = json.dumps(contact).encode("utf-8")
yielding a response with the following shape:

  id: string;
  alias: string;
  oobi: string;

Is it intentional? If yes, what is the preferred way to get the current challenge responses for a specific contact? If not, should we add this information to ContactResource as well?

Another option could be to remove the challenges from the ContactCollectionResource as well and add a new endpoint /contacts/{prefix}/challenges. Thoughts?

@lenkan
Copy link
Collaborator Author

lenkan commented Jan 25, 2024

I also noticed that in keria, we have four "methods" for challenges, but in keripy / kli we only have three.

  • generate => generate challenge words
  • verify => wait for signed challenge response
  • response => sign a challenge and send to the "verifier"
  • accept => mark the challenge as "verified"/"authenticated" (This is done by the verify step in keripy, where as in keria it is an additional request).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant