limit access to cache

This commit is contained in:
Cayo Puigdefabregas 2024-02-21 10:46:33 +01:00
parent d45be274ee
commit e558d9145d
6 changed files with 7 additions and 18 deletions

View file

@ -68,6 +68,7 @@ class EncryptionKeyForm(forms.Form):
txt = _("Key no valid!")
raise ValidationError(txt)
cache.set("KEY_DIDS", None)
return data
def save(self, commit=True):
@ -426,8 +427,7 @@ class ImportCertificateForm(forms.Form):
type=DID.Types.KEY
)
pw = cache.get("KEY_DIDS")
self._did.set_key_material(key_material, pw)
self._did.set_key_material(key_material)
def save(self, commit=True):

View file

@ -701,15 +701,10 @@ class DeleteCredentialsView(Credentials):
VerificableCredential,
pk=pk,
)
status = [
VerificableCredential.Status.REVOKED,
VerificableCredential.Status.ISSUED
]
if self.object.status in status:
self.object.delete()
messages.success(self.request, _('Credential deleted successfully'))
Event.set_EV_CREDENTIAL_DELETED(self.object)
Event.set_EV_CREDENTIAL_DELETED_BY_ADMIN(self.object)
self.object.delete()
messages.success(self.request, _('Credential deleted successfully'))
Event.set_EV_CREDENTIAL_DELETED(self.object)
Event.set_EV_CREDENTIAL_DELETED_BY_ADMIN(self.object)
return redirect(self.success_url)

View file

@ -1,6 +1,5 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.utils.translation import gettext_lazy as _
from django.contrib.auth import views as auth_views
from django.core.exceptions import PermissionDenied
from django.urls import reverse_lazy, resolve
from django.shortcuts import redirect

View file

@ -6,7 +6,6 @@ import datetime
from collections import OrderedDict
from django.db import models
from django.conf import settings
from django.core.cache import cache
from django.template.loader import get_template
from django.utils.translation import gettext_lazy as _

View file

@ -1,8 +1,6 @@
import os
import json
import base64
import qrcode
import logging
import datetime
import weasyprint
import qrcode.image.svg
@ -34,7 +32,6 @@ from idhub.user.tables import (
DIDTable,
CredentialsTable
)
from django.core.cache import cache
from idhub.user.forms import (
RequestCredentialForm,
DemandAuthorizationForm,
@ -172,7 +169,7 @@ class WaitingView(UserView, TemplateView):
success_url = reverse_lazy('idhub:user_dashboard')
def get(self, request, *args, **kwargs):
if cache.get("KEY_DIDS"):
if self.admin_validated:
return redirect(self.success_url)
return super().get(request, *args, **kwargs)

View file

@ -6,7 +6,6 @@ import zlib
import pyroaring
from django.conf import settings
from django.core.cache import cache
from django.urls import reverse_lazy
from django.views.generic.base import TemplateView
from django.contrib.auth import views as auth_views