demand authorization get to verifier
This commit is contained in:
parent
cfbbaf491e
commit
5e95d6b15c
105
oidc4vp/views.py
105
oidc4vp/views.py
|
@ -2,7 +2,7 @@ import json
|
||||||
|
|
||||||
from django.views.generic.edit import View
|
from django.views.generic.edit import View
|
||||||
|
|
||||||
from oidc4vp.models import Authorization
|
from oidc4vp.models import Authorization, Organization
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,69 +11,56 @@ from django.http import HttpResponse
|
||||||
|
|
||||||
# from utils.idhub_ssikit import verify_presentation
|
# from utils.idhub_ssikit import verify_presentation
|
||||||
# from oidc4vp.models import VPVerifyRequest
|
# from oidc4vp.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
|
||||||
|
|
||||||
|
|
||||||
class VerifyView(View):
|
class VerifyView(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
org_url = request.GET.get('demand_uri')
|
||||||
|
org = get_object_or_404(Organization, response_uri=org_url)
|
||||||
|
authorization = Authorization(
|
||||||
|
organization=org,
|
||||||
|
presentation_definition="MemberCredential"
|
||||||
|
)
|
||||||
import pdb; pdb.set_trace()
|
import pdb; pdb.set_trace()
|
||||||
res = json.dumps({"uri": "http://localhost:10000"})
|
res = json.dumps({"redirect_uri": authorization.authorize()})
|
||||||
return HttpResponse(res)
|
return HttpResponse(res)
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
def DemandAuthorizationView(request):
|
import pdb; pdb.set_trace()
|
||||||
assert request.method == "GET"
|
# # TODO: incorporate request.POST["presentation_submission"] as schema definition
|
||||||
import pdb; pdb.set_trace()
|
# (presentation_valid, _) = verify_presentation(request.POST["vp_token"])
|
||||||
params = request.GET.params
|
# if not presentation_valid:
|
||||||
org = Organization.objects.filter(
|
# raise Exception("Failed to verify signature on the given Verifiable Presentation.")
|
||||||
url=params.get('redirect_uri')
|
# vp = json.loads(request.POST["vp_token"])
|
||||||
)
|
# nonce = vp["nonce"]
|
||||||
authorization = Authorization(
|
# # "vr" = verification_request
|
||||||
organization=org,
|
# vr = get_object_or_404(VPVerifyRequest, nonce=nonce) # TODO: return meaningful error, not 404
|
||||||
presentation_definition="MemberCredential"
|
# # Get a list of all included verifiable credential types
|
||||||
)
|
# included_credential_types = unique_everseen(flatten([
|
||||||
# authorization.save()
|
# vc["type"] for vc in vp["verifiableCredential"]
|
||||||
res = json.dumps({"uri": authorization.authorize()})
|
# ]))
|
||||||
return HttpResponse(res)
|
# # Check that it matches what we requested
|
||||||
|
# for requested_vc_type in json.loads(vr.expected_credentials):
|
||||||
|
# if requested_vc_type not in included_credential_types:
|
||||||
def verify(request):
|
# raise Exception("You're missing some credentials we requested!") # TODO: return meaningful error
|
||||||
import pdb; pdb.set_trace()
|
# # Perform whatever action we have to do
|
||||||
# assert request.method == "POST"
|
# action = json.loads(vr.action)
|
||||||
# # TODO: incorporate request.POST["presentation_submission"] as schema definition
|
# if action["action"] == "send_mail":
|
||||||
# (presentation_valid, _) = verify_presentation(request.POST["vp_token"])
|
# subject = action["params"]["subject"]
|
||||||
# if not presentation_valid:
|
# to_email = action["params"]["to"]
|
||||||
# raise Exception("Failed to verify signature on the given Verifiable Presentation.")
|
# from_email = "noreply@verifier-portal"
|
||||||
# vp = json.loads(request.POST["vp_token"])
|
# body = request.POST["vp-token"]
|
||||||
# nonce = vp["nonce"]
|
# send_mail(
|
||||||
# # "vr" = verification_request
|
# subject,
|
||||||
# vr = get_object_or_404(VPVerifyRequest, nonce=nonce) # TODO: return meaningful error, not 404
|
# body,
|
||||||
# # Get a list of all included verifiable credential types
|
# from_email,
|
||||||
# included_credential_types = unique_everseen(flatten([
|
# [to_email]
|
||||||
# vc["type"] for vc in vp["verifiableCredential"]
|
# )
|
||||||
# ]))
|
# elif action["action"] == "something-else":
|
||||||
# # Check that it matches what we requested
|
# pass
|
||||||
# for requested_vc_type in json.loads(vr.expected_credentials):
|
# else:
|
||||||
# if requested_vc_type not in included_credential_types:
|
# raise Exception("Unknown action!")
|
||||||
# raise Exception("You're missing some credentials we requested!") # TODO: return meaningful error
|
# # OK! Your verifiable presentation was successfully presented.
|
||||||
# # Perform whatever action we have to do
|
# return HttpResponseRedirect(vr.response_or_redirect)
|
||||||
# action = json.loads(vr.action)
|
|
||||||
# if action["action"] == "send_mail":
|
|
||||||
# subject = action["params"]["subject"]
|
|
||||||
# to_email = action["params"]["to"]
|
|
||||||
# from_email = "noreply@verifier-portal"
|
|
||||||
# body = request.POST["vp-token"]
|
|
||||||
# send_mail(
|
|
||||||
# subject,
|
|
||||||
# body,
|
|
||||||
# from_email,
|
|
||||||
# [to_email]
|
|
||||||
# )
|
|
||||||
# elif action["action"] == "something-else":
|
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# raise Exception("Unknown action!")
|
|
||||||
# # OK! Your verifiable presentation was successfully presented.
|
|
||||||
# return HttpResponseRedirect(vr.response_or_redirect)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue