Merge branch 'release'

This commit is contained in:
Cayo Puigdefabregas 2024-03-12 11:47:50 +01:00
commit c204250397
15 changed files with 180 additions and 38 deletions

View File

@ -0,0 +1,2 @@
"localhost idhub1";"http://localhost/oidc4vp/";"localhost"
"localhost idhub2";"http://idhub2/oidc4vp/";"idhub2"
1 localhost idhub1 http://localhost/oidc4vp/ localhost
2 localhost idhub2 http://idhub2/oidc4vp/ idhub2

View File

@ -217,13 +217,13 @@ class ImportForm(forms.Form):
return data
def clean_file_import(self):
props = self.json_schema.get("properties", {})
data = self.cleaned_data["file_import"]
self.file_name = data.name
if not self._schema:
return data
self.file_name = data.name
props = self.json_schema.get("properties", {})
# Forze than pandas read one column as string
dtype_dict = {"phoneNumber": str}
df = pd.read_excel(data, dtype=dtype_dict)

View File

@ -11,6 +11,7 @@
</div>
<div class="col text-end">
{% if object.get_status == 'Issued' %}
<a class="btn btn-green-admin me-2" href="{% url 'idhub:admin_credential_json' object.id %}">{% trans 'Download as JSON' %}</a>
<a class="btn btn-yellow" class="btn btn-orange" data-bs-toggle="modal" data-bs-target="#confirm-revoke" href="javascript:void()">{% trans 'Revoke' %}</a>
{% endif %}
{% if object.get_status == 'Enabled' %}
@ -48,13 +49,6 @@
{{ object.get_status}}
</div>
</div>
{% if object.issued_on %}
<div class="row mt-3">
<div class="col text-center">
<a class="btn btn-green-admin" href="{% url 'idhub:admin_credential_json' object.id %}">{% trans 'Download in JSON format' %}</a>
</div>
</div>
{% endif %}
</div>
</div>
<!-- Modal Revoke -->

View File

@ -2,10 +2,29 @@
{% load i18n %}
{% block content %}
<div class="row">
<div class="col">
<h3>
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
</div>
<div class="col text-end">
{% if object.get_status == 'Issued' %}
<div class="col">
{% if object.eidas1_did and admin_validated %}
<a class="btn btn-green-user me-2" href="{% url 'idhub:user_credential_pdf' object.id %}">{% trans 'Download as PDF' %}</a>
{% endif %}
<a class="btn btn-green-user" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Download as JSON' %}</a>
</div>
{% endif %}
{% if object.get_status == 'Enabled' %}
<div class="col">
<a class="btn btn-green-user" href="{% url 'idhub:user_credentials_request' %}">{% trans 'Request credential' %}</a>
</div>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-3">
</div>
@ -38,21 +57,5 @@
</div>
</div>
</div>
{% if object.get_status == 'Issued' %}
<div class="row mt-3">
{% if object.eidas1_did and admin_validated %}
<div class="col text-center">
<a class="btn btn-green-user" href="{% url 'idhub:user_credential_pdf' object.id %}">{% trans 'Sign credential in PDF format' %}</a>
</div>
{% endif %}
<div class="col text-center">
<a class="btn btn-green-user" href="{% url 'idhub:user_credential_json' object.id %}">{% trans 'Download credential in JSON format' %}</a>
</div>
{% endif %}
{% if object.get_status == 'Enabled' %}
<div class="col text-center">
<a class="btn btn-green-user" href="{% url 'idhub:user_credentials_request' %}">{% trans 'Request credential' %}</a>
</div>
{% endif %}
</div>
{% endblock %}

View File

@ -20,6 +20,7 @@
</div>
</div>
{% endif %}
{% if form.if_credentials %}
<div class="row">
<div class="col-sm-4">
{% bootstrap_form form %}
@ -29,6 +30,13 @@
<a class="btn btn-grey" href="{% url 'idhub:user_credentials' %}">{% trans "Cancel" %}</a>
<input class="btn btn-green-user" type="submit" name="submit" value="{% trans 'Send' %}" />
</div>
{% else %}
<div class="row">
<div class="col-sm-4">
{% trans 'Sorry no there are credentials to present' %}
</div>
</div>
{% endif %}
</form>
{% endblock %}

View File

@ -20,6 +20,7 @@
</div>
</div>
{% endif %}
{% if form.if_credentials %}
<div class="row">
<div class="col-sm-4">
{% bootstrap_form form %}
@ -29,6 +30,12 @@
<a class="btn btn-grey" href="{% url 'idhub:user_credentials' %}">{% trans "Cancel" %}</a>
<input class="btn btn-green-user" type="submit" name="submit" value="{% trans 'Request' %}" />
</div>
{% else %}
<div class="row">
<div class="col-sm-4">
{% trans 'Sorry no there are credentials enabled' %}
</div>
</div>
{% endif %}
</form>
{% endblock %}

View File

@ -86,6 +86,7 @@ class RequestCredentialForm(forms.Form):
self.user = kwargs.pop('user', None)
self.lang = kwargs.pop('lang', None)
self._domain = kwargs.pop('domain', None)
self.if_credentials = kwargs.pop('if_credentials', None)
super().__init__(*args, **kwargs)
self.fields['did'].choices = [
(x.did, x.label) for x in DID.objects.filter(user=self.user)
@ -130,6 +131,7 @@ class DemandAuthorizationForm(forms.Form):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
self.if_credentials = kwargs.pop('if_credentials', None)
super().__init__(*args, **kwargs)
self.fields['organization'].choices = [
(x.id, x.name) for x in Organization.objects.exclude(

View File

@ -392,18 +392,26 @@ class CredentialsRequestView(MyWallet, FormView):
form_class = RequestCredentialForm
success_url = reverse_lazy('idhub:user_credentials')
def get(self, request, *args, **kwargs):
response = super().get(request, *args, **kwargs)
if not cache.get("KEY_DIDS"):
return redirect(reverse_lazy('idhub:user_waiting'))
def get(self, *args, **kwargs):
response = super().get(*args, **kwargs)
if not DID.objects.filter(user=self.request.user).exists():
return redirect(reverse_lazy('idhub:user_dids_new'))
return response
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
self.if_credentials = VerificableCredential.objects.filter(
user=self.request.user,
status=VerificableCredential.Status.ENABLED.value,
).exists()
kwargs['user'] = self.request.user
kwargs['lang'] = self.request.LANGUAGE_CODE
domain = "{}://{}".format(self.request.scheme, self.request.get_host())
kwargs['domain'] = domain
kwargs['if_credentials'] = self.if_credentials
return kwargs
def form_valid(self, form):
@ -427,9 +435,26 @@ class DemandAuthorizationView(MyWallet, FormView):
form_class = DemandAuthorizationForm
success_url = reverse_lazy('idhub:user_demand_authorization')
def get(self, *args, **kwargs):
response = super().get(*args, **kwargs)
creds_enable = VerificableCredential.objects.filter(
user=self.request.user,
status=VerificableCredential.Status.ENABLED.value,
).exists()
if not self.if_credentials and creds_enable:
return redirect(reverse_lazy('idhub:user_credentials_request'))
return response
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
self.if_credentials = VerificableCredential.objects.filter(
user=self.request.user,
status=VerificableCredential.Status.ISSUED.value,
).exists()
kwargs['user'] = self.request.user
kwargs['if_credentials'] = self.if_credentials
return kwargs
def form_valid(self, form):

View File

@ -286,10 +286,10 @@ class OAuth2VPToken(models.Model):
}
verification = json.loads(self.result_verify)
if verification.get('errors') or verification.get('warnings'):
response["verify"] = "Error, Verification Failed"
response["verify"] = "Error, {}".format(_("Failed verification"))
return response
response["verify"] = "Ok, Verification correct"
response["verify"] = "Ok, {}".format(_("Correct verification"))
url = self.get_redirect_url()
if url:
response["redirect_uri"] = url

View File

@ -0,0 +1,10 @@
Hola, hay una nueva verificación en el servicio de verificación Idhub {{ domain }}
<br />
El código asociado a esta verificación es: {{ code }}
<br />
estos son los datos de la verificación:
<br />
{{ verification|safe }}
<br />
Muchas gracias

View File

@ -0,0 +1,6 @@
Hola, hay una nueva verificación en el servicio de verificación Idhub {{ domain }}
El código asociado a esta verificación es: {{ code }}
estos son los datos de la verificación:
{{ verification|safe }}
Muchas gracias

View File

@ -0,0 +1 @@
Nueva verificacion en {{ dominio }}

View File

@ -0,0 +1,72 @@
{% load i18n static %}
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="NONE,NOARCHIVE" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Pangea">
<title>{% block title %}{% if title %}{{ title }} {% endif %}Pangea{% endblock %}</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<link rel="stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
<link href="{% static "/css/bootstrap.min.css" %}" rel="stylesheet">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link href="{% static "/css/dashboard.css" %}" rel="stylesheet">
</head>
<body id="body-login">
<header class="navbar navbar-dark sticky-top bg-grey flex-md-nowrap p-0 shadow" style="background-color: #712547;">
<div class="navbar-nav navbar-sub-brand">
</div>
<div class="navbar-nav">
</div>
</header>
<div class="container-fluid">
<div class="row">
<main class="col-md-12 bt-5">
<div class="jumbotron vertical-center">
<div id="login-wrapper" class="container" style="width: 430px;">
<div id="login-content" class="rounded">
<div id="login-branding">
</div><!-- /login-branding -->
<div class="mt-5">
<div class="row">
<div class="col">
{% trans 'Thank you, we are received your presentation correctly.' %}
</div>
</div>
</div><!-- /.row-fluid -->
</div>
<!--/#login-content-->
</div><!-- /#login-wrapper -->
</div><!-- /.jumbotron -->
</main>
</div>
</div>
</body>
</html>

View File

@ -13,4 +13,6 @@ urlpatterns = [
name="authorize"),
path('allow_code', views.AllowCodeView.as_view(),
name="allow_code"),
path('received_code', views.ReceivedCodeView.as_view(),
name="received_code"),
]

View File

@ -235,7 +235,17 @@ class AllowCodeView(View):
promotion = self.authorization.promotions.first()
if not promotion:
raise Http404("Page not Found!")
return redirect(reverse_lazy('oidc4vp:received_code'))
return redirect(promotion.get_url(code))
class ReceivedCodeView(View):
template_name = "received_code.html"
def get(self, request, *args, **kwargs):
self.context = {}
template = loader.get_template(
self.template_name,
).render()
return HttpResponse(template)