admin2fauth
This commit is contained in:
parent
6babea9f55
commit
b031f2ac08
|
@ -48,6 +48,24 @@ from idhub.models import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class DobleFactorAuthView(AdminView):
|
||||||
|
url = reverse_lazy('idhub:admin_dashboard')
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
import pdb; pdb.set_trace()
|
||||||
|
if not self.request.session.get("2fauth"):
|
||||||
|
return redirect(self.url)
|
||||||
|
|
||||||
|
if self.request.session.get("2fauth") == '0c9116a7-c6e5-41d7-bbf0-e8492cdfca23'
|
||||||
|
if not request.user.is_admin:
|
||||||
|
return redirect(url)
|
||||||
|
|
||||||
|
if self.request.session.get("2fauth"):
|
||||||
|
return redirect(reverse_lazy("idhub:login"))
|
||||||
|
|
||||||
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DashboardView(AdminView, SingleTableView):
|
class DashboardView(AdminView, SingleTableView):
|
||||||
template_name = "idhub/admin/dashboard.html"
|
template_name = "idhub/admin/dashboard.html"
|
||||||
table_class = DashboardTable
|
table_class = DashboardTable
|
||||||
|
|
|
@ -30,4 +30,7 @@ class AdminView(UserView):
|
||||||
url = reverse_lazy('idhub:user_dashboard')
|
url = reverse_lazy('idhub:user_dashboard')
|
||||||
return redirect(url)
|
return redirect(url)
|
||||||
|
|
||||||
|
if self.request.session.get("2fauth"):
|
||||||
|
return redirect(reverse_lazy("idhub:login"))
|
||||||
|
|
||||||
return super().get(request, *args, **kwargs)
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
|
@ -175,6 +175,8 @@ urlpatterns = [
|
||||||
name='admin_import'),
|
name='admin_import'),
|
||||||
path('admin/import/new', views_admin.ImportAddView.as_view(),
|
path('admin/import/new', views_admin.ImportAddView.as_view(),
|
||||||
name='admin_import_add'),
|
name='admin_import_add'),
|
||||||
|
path('admin/auth/<uuid:2fauth>', views_admin.DobleFactorAuthView.as_view(),
|
||||||
|
name='admin_2fauth'),
|
||||||
|
|
||||||
path('did-registry/<str:did_id>/did.json', serve_did)
|
path('did-registry/<str:did_id>/did.json', serve_did)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import uuid
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -41,6 +42,8 @@ class LoginView(auth_views.LoginView):
|
||||||
# )
|
# )
|
||||||
# cache.set("KEY_DIDS", encryption_key, None)
|
# cache.set("KEY_DIDS", encryption_key, None)
|
||||||
cache.set("KEY_DIDS", sensitive_data_encryption_key, None)
|
cache.set("KEY_DIDS", sensitive_data_encryption_key, None)
|
||||||
|
# self.request.session["2fauth"] = uuid.uuid4()
|
||||||
|
self.request.session["2fauth"] = '0c9116a7-c6e5-41d7-bbf0-e8492cdfca23'
|
||||||
|
|
||||||
self.request.session["key_did"] = user.encrypt_data(
|
self.request.session["key_did"] = user.encrypt_data(
|
||||||
sensitive_data_encryption_key,
|
sensitive_data_encryption_key,
|
||||||
|
|
Loading…
Reference in New Issue