From 7c6185b581cbcd2ee2a16dc2357d92ba20a74395 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 21 May 2021 19:53:40 +0200 Subject: [PATCH] api: fix URL names for admin Authenticator Views Signed-off-by: Jens Langhammer --- authentik/api/v2/urls.py | 16 +++++++++++++--- authentik/lib/views.py | 22 ---------------------- authentik/stages/dummy/tests.py | 3 +-- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/authentik/api/v2/urls.py b/authentik/api/v2/urls.py index d46be9528..067c938de 100644 --- a/authentik/api/v2/urls.py +++ b/authentik/api/v2/urls.py @@ -169,9 +169,19 @@ router.register("propertymappings/scope", ScopeMappingViewSet) router.register("authenticators/static", StaticDeviceViewSet) router.register("authenticators/totp", TOTPDeviceViewSet) router.register("authenticators/webauthn", WebAuthnDeviceViewSet) -router.register("authenticators/admin/static", StaticAdminDeviceViewSet) -router.register("authenticators/admin/totp", TOTPAdminDeviceViewSet) -router.register("authenticators/admin/webauthn", WebAuthnAdminDeviceViewSet) +router.register( + "authenticators/admin/static", + StaticAdminDeviceViewSet, + basename="admin-staticdevice", +) +router.register( + "authenticators/admin/totp", TOTPAdminDeviceViewSet, basename="admin-totpdevice" +) +router.register( + "authenticators/admin/webauthn", + WebAuthnAdminDeviceViewSet, + basename="admin-webauthndevice", +) router.register("stages/all", StageViewSet) router.register("stages/authenticator/static", AuthenticatorStaticStageViewSet) diff --git a/authentik/lib/views.py b/authentik/lib/views.py index bfa28414e..f444dd2d6 100644 --- a/authentik/lib/views.py +++ b/authentik/lib/views.py @@ -2,28 +2,6 @@ from django.http import HttpRequest from django.template.response import TemplateResponse from django.utils.translation import gettext_lazy as _ -from django.views.generic import CreateView -from guardian.shortcuts import assign_perm - - -class CreateAssignPermView(CreateView): - """Assign permissions to object after creation""" - - permissions = [ - "%s.view_%s", - "%s.change_%s", - "%s.delete_%s", - ] - - def form_valid(self, form): - response = super().form_valid(form) - for permission in self.permissions: - full_permission = permission % ( - self.object._meta.app_label, - self.object._meta.model_name, - ) - assign_perm(full_permission, self.request.user, self.object) - return response def bad_request_message( diff --git a/authentik/stages/dummy/tests.py b/authentik/stages/dummy/tests.py index b943d391e..1bfdef559 100644 --- a/authentik/stages/dummy/tests.py +++ b/authentik/stages/dummy/tests.py @@ -1,5 +1,5 @@ """dummy tests""" -from django.test import Client, TestCase +from django.test import TestCase from django.urls import reverse from django.utils.encoding import force_str @@ -14,7 +14,6 @@ class TestDummyStage(TestCase): def setUp(self): super().setUp() self.user = User.objects.create(username="unittest", email="test@beryju.org") - self.client = Client() self.flow = Flow.objects.create( name="test-dummy",