fix models
This commit is contained in:
parent
d84ad8f470
commit
4a3cf5c5df
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.2.5 on 2023-11-24 17:10
|
# Generated by Django 4.2.5 on 2023-11-29 09:52
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -59,6 +59,18 @@ class Migration(migrations.Migration):
|
||||||
default=oidc4vp.models.set_client_secret, max_length=48
|
default=oidc4vp.models.set_client_secret, max_length=48
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
'my_client_id',
|
||||||
|
models.CharField(
|
||||||
|
default=oidc4vp.models.set_client_id, max_length=24, unique=True
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'my_client_secret',
|
||||||
|
models.CharField(
|
||||||
|
default=oidc4vp.models.set_client_secret, max_length=48
|
||||||
|
),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
'response_uri',
|
'response_uri',
|
||||||
models.URLField(
|
models.URLField(
|
||||||
|
@ -68,6 +80,26 @@ class Migration(migrations.Migration):
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VPVerifyRequest',
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
'id',
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name='ID',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
('nonce', models.CharField(max_length=50)),
|
||||||
|
('expected_credentials', models.CharField(max_length=255)),
|
||||||
|
('expected_contents', models.TextField()),
|
||||||
|
('action', models.TextField()),
|
||||||
|
('response_or_redirect', models.CharField(max_length=255)),
|
||||||
|
('submitted_on', models.DateTimeField(auto_now=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='OAuth2VPToken',
|
name='OAuth2VPToken',
|
||||||
fields=[
|
fields=[
|
||||||
|
|
|
@ -33,7 +33,14 @@ def set_code():
|
||||||
|
|
||||||
class Organization(models.Model):
|
class Organization(models.Model):
|
||||||
"""
|
"""
|
||||||
This class represent a member of one net trust or federated host
|
This class represent a member of one net trust or federated host.
|
||||||
|
Client_id and client_secret are the credentials of this organization
|
||||||
|
get a connection to my. (receive a request)
|
||||||
|
My_client_id and my_client_secret are my credentials than to use if I
|
||||||
|
want to connect to this organization. (send a request)
|
||||||
|
For use the packages requests we need use my_client_id
|
||||||
|
For use in the get or post method of a View, then we need use client_id
|
||||||
|
and secret_id
|
||||||
"""
|
"""
|
||||||
name = models.CharField(max_length=250)
|
name = models.CharField(max_length=250)
|
||||||
client_id = models.CharField(
|
client_id = models.CharField(
|
||||||
|
@ -45,6 +52,15 @@ class Organization(models.Model):
|
||||||
max_length=48,
|
max_length=48,
|
||||||
default=set_client_secret
|
default=set_client_secret
|
||||||
)
|
)
|
||||||
|
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(
|
response_uri = models.URLField(
|
||||||
help_text=_("Url where to send the verificable presentation"),
|
help_text=_("Url where to send the verificable presentation"),
|
||||||
max_length=250
|
max_length=250
|
||||||
|
@ -54,11 +70,8 @@ class Organization(models.Model):
|
||||||
"""
|
"""
|
||||||
Send the verificable presentation to Verifier
|
Send the verificable presentation to Verifier
|
||||||
"""
|
"""
|
||||||
org = self.__class__.objects.get(
|
auth = (self.my_client_id, self.client_secret)
|
||||||
response_uri=settings.RESPONSE_URI
|
return requests.post(self.response_uri, data=vp, auth=auth)
|
||||||
)
|
|
||||||
auth = (org.client_id, org.client_secret)
|
|
||||||
return requests.post(self.url, data=vp, auth=auth)
|
|
||||||
|
|
||||||
def demand_authorization(self):
|
def demand_authorization(self):
|
||||||
"""
|
"""
|
||||||
|
@ -72,7 +85,7 @@ class Organization(models.Model):
|
||||||
url=self.response_uri.strip("/"),
|
url=self.response_uri.strip("/"),
|
||||||
redirect_uri=settings.RESPONSE_URI
|
redirect_uri=settings.RESPONSE_URI
|
||||||
)
|
)
|
||||||
auth = (org.client_id, org.client_secret)
|
auth = (self.my_client_id, self.client_secret)
|
||||||
return requests.get(url, auth=auth)
|
return requests.get(url, auth=auth)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in New Issue