Skip to content
Snippets Groups Projects
Verified Commit 94b1c0fa authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Return all matching keys

parent b75eb24c
No related branches found
No related tags found
1 merge request!18Draft: Resolve "HKP fails if multiple keys match"
Pipeline #9081 failed
......@@ -18,11 +18,14 @@ def lookup(request):
if search.startswith("0x"):
search = search[2:]
key = get_object_or_404(models.PublicKey, keyid__endswith=search)
if not request.user.has_perm("pgp.view_publickey", key):
keys = models.PublicKey.objects.filter(keyid__endswith=search)
keys = [key for key in keys
if request.user.has_perm("pgp.view_publickey", key)]
if not keys:
raise Http404()
response = HttpResponse(key.armor, content_type="application/pgp-keys")
response = HttpResponse("\n".join(k.armor for k in keys),
content_type="application/pgp-keys")
response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Methods"] = "GET, OPTIONS, HEAD"
return response
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment