From 37d3430680d0cf540cf4018a24e6f6b2627d241c Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 29 Nov 2023 11:18:12 +0100 Subject: [PATCH] fix credentials --- oidc4vp/models.py | 5 +---- oidc4vp/views.py | 9 +++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/oidc4vp/models.py b/oidc4vp/models.py index 3a711bf..94c30c5 100644 --- a/oidc4vp/models.py +++ b/oidc4vp/models.py @@ -54,12 +54,9 @@ class Organization(models.Model): ) my_client_id = models.CharField( max_length=24, - default=set_client_id, - unique=True ) my_client_secret = models.CharField( max_length=48, - default=set_client_secret ) response_uri = models.URLField( help_text=_("Url where to send the verificable presentation"), @@ -128,7 +125,7 @@ class Authorization(models.Model): data = { "response_type": "vp_token", "response_mode": "direct_post", - "client_id": self.organization.client_id, + "client_id": self.organization.my_client_id, "presentation_definition": self.presentation_definition, "nonce": gen_salt(5), } diff --git a/oidc4vp/views.py b/oidc4vp/views.py index 77a97b6..7e8ce0e 100644 --- a/oidc4vp/views.py +++ b/oidc4vp/views.py @@ -19,13 +19,13 @@ from django.shortcuts import get_object_or_404 class VerifyView(View): def get(self, request, *args, **kwargs): org = self.validate(request) - if not org: - raise Http404("Page not Found!") - + # TODO Not hardcode the list of types of presentation_definition + presentation_definition = json.dumps(['MemberCredential']) authorization = Authorization( organization=org, - presentation_definition="MemberCredential" + presentation_definition=presentation_definition ) + res = json.dumps({"redirect_uri": authorization.authorize()}) return HttpResponse(res) def validate(self, request): @@ -45,6 +45,7 @@ class VerifyView(View): return org def post(self, request, *args, **kwargs): + org = self.validate(request) import pdb; pdb.set_trace() # # TODO: incorporate request.POST["presentation_submission"] as schema definition # (presentation_valid, _) = verify_presentation(request.POST["vp_token"])