minor changes to verifier

This commit is contained in:
Daniel Armengod 2023-11-27 07:11:39 +01:00
parent 737d2a7dce
commit 2c4dca40b7
2 changed files with 7 additions and 3 deletions

View File

@ -3,7 +3,8 @@ from django.db import models
class VPVerifyRequest(models.Model): class VPVerifyRequest(models.Model):
""" """
`nonce` is an opaque random string used to lookup verification requests `nonce` is an opaque random string used to lookup verification requests. URL-safe.
Example: "UPBQ3JE2DGJYHP5CPSCRIGTHRTCYXMQPNQ"
`expected_credentials` is a JSON list of credential types that must be present in this VP. `expected_credentials` is a JSON list of credential types that must be present in this VP.
Example: ["FinancialSituationCredential", "HomeConnectivitySurveyCredential"] Example: ["FinancialSituationCredential", "HomeConnectivitySurveyCredential"]
`expected_contents` is a JSON object that places optional constraints on the contents of the `expected_contents` is a JSON object that places optional constraints on the contents of the
@ -12,10 +13,12 @@ class VPVerifyRequest(models.Model):
`action` is (for now) a JSON object describing the next steps to take if this verification `action` is (for now) a JSON object describing the next steps to take if this verification
is successful. For example "send mail to <destination> with <subject> and <body>" is successful. For example "send mail to <destination> with <subject> and <body>"
Example: {"action": "send_mail", "params": {"to": "orders@somconnexio.coop", "subject": "New client", "body": ...} Example: {"action": "send_mail", "params": {"to": "orders@somconnexio.coop", "subject": "New client", "body": ...}
`response` is a URL that the user's wallet will redirect the user to.
`submitted_on` is used (by a cronjob) to purge old entries that didn't complete verification `submitted_on` is used (by a cronjob) to purge old entries that didn't complete verification
""" """
nonce = models.CharField(max_length=50) nonce = models.CharField(max_length=50)
expected_credentials = models.CharField(max_length=255) expected_credentials = models.CharField(max_length=255)
expected_contents = models.TextField() expected_contents = models.TextField()
action = models.TextField() action = models.TextField()
response_or_redirect = models.CharField(max_length=255)
submitted_on = models.DateTimeField(auto_now=True) submitted_on = models.DateTimeField(auto_now=True)

View File

@ -1,7 +1,7 @@
import json import json
from django.core.mail import send_mail from django.core.mail import send_mail
from django.http import HttpResponse from django.http import HttpResponse, HttpResponseRedirect
from .models import VPVerifyRequest from .models import VPVerifyRequest
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from more_itertools import flatten, unique_everseen from more_itertools import flatten, unique_everseen
@ -39,5 +39,6 @@ def verify(request):
pass pass
else: else:
raise Exception("Unknown action!") raise Exception("Unknown action!")
return HttpResponse("OK! Your verifiable presentation was successfully presented.") # OK! Your verifiable presentation was successfully presented.
return HttpResponseRedirect(vr.response_or_redirect)