From 42cb55d78ab61a91b30e0a7f58416bdd7ae471a3 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 3 Apr 2021 11:32:17 +0200 Subject: [PATCH] *: rename objectType to component to get rid of lookup tables Signed-off-by: Jens Langhammer --- authentik/admin/tests/test_generated.py | 66 ------- authentik/core/api/propertymappings.py | 10 +- authentik/core/api/providers.py | 10 +- authentik/core/api/sources.py | 10 +- authentik/flows/api/stages.py | 13 +- authentik/flows/tests/test_api.py | 2 +- authentik/flows/transfer/common.py | 2 +- .../api/outpost_service_connections.py | 10 +- authentik/policies/api/policies.py | 10 +- authentik/policies/dummy/models.py | 2 +- .../migrations/0007_auto_20210403_0927.py | 32 ++++ .../stages/authenticator_validate/models.py | 2 +- authentik/stages/user_delete/tests.py | 18 -- swagger.yaml | 169 +++++++++--------- web/src/pages/flows/BoundStagesList.ts | 24 ++- .../outposts/ServiceConnectionListPage.ts | 6 +- web/src/pages/policies/BoundPoliciesList.ts | 28 ++- web/src/pages/policies/PolicyListPage.ts | 11 +- .../PropertyMappingListPage.ts | 7 +- web/src/pages/providers/ProviderListPage.ts | 7 +- web/src/pages/providers/ProviderViewPage.ts | 10 +- web/src/pages/sources/SourceViewPage.ts | 10 +- web/src/pages/sources/SourcesListPage.ts | 7 +- web/src/pages/stages/StageListPage.ts | 46 ++--- .../AuthenticatorValidateStageForm.ts | 15 +- .../identification/IdentificationStageForm.ts | 4 +- 26 files changed, 236 insertions(+), 295 deletions(-) delete mode 100644 authentik/admin/tests/test_generated.py create mode 100644 authentik/stages/authenticator_validate/migrations/0007_auto_20210403_0927.py diff --git a/authentik/admin/tests/test_generated.py b/authentik/admin/tests/test_generated.py deleted file mode 100644 index af63fe1edb..0000000000 --- a/authentik/admin/tests/test_generated.py +++ /dev/null @@ -1,66 +0,0 @@ -"""admin tests""" -from importlib import import_module -from typing import Callable - -from django.forms import ModelForm -from django.test import Client, TestCase -from django.urls import reverse -from django.urls.exceptions import NoReverseMatch - -from authentik.admin.urls import urlpatterns -from authentik.core.models import Group, User -from authentik.lib.utils.reflection import get_apps - - -class TestAdmin(TestCase): - """Generic admin tests""" - - def setUp(self): - self.user = User.objects.create_user(username="test") - self.user.ak_groups.add(Group.objects.filter(is_superuser=True).first()) - self.user.save() - self.client = Client() - self.client.force_login(self.user) - - -def generic_view_tester(view_name: str) -> Callable: - """This is used instead of subTest for better visibility""" - - def tester(self: TestAdmin): - try: - full_url = reverse(f"authentik_admin:{view_name}") - response = self.client.get(full_url) - self.assertTrue(response.status_code < 500) - except NoReverseMatch: - pass - - return tester - - -for url in urlpatterns: - method_name = url.name.replace("-", "_") - setattr(TestAdmin, f"test_view_{method_name}", generic_view_tester(url.name)) - - -def generic_form_tester(form: ModelForm) -> Callable: - """Test a form""" - - def tester(self: TestAdmin): - form_inst = form() - self.assertFalse(form_inst.is_valid()) - - return tester - - -# Load the forms module from every app, so we have all forms loaded -for app in get_apps(): - module = app.__module__.replace(".apps", ".forms") - try: - import_module(module) - except ImportError: - pass - -for form_class in ModelForm.__subclasses__(): - setattr( - TestAdmin, f"test_form_{form_class.__name__}", generic_form_tester(form_class) - ) diff --git a/authentik/core/api/propertymappings.py b/authentik/core/api/propertymappings.py index f790ad7c30..008a09d3ad 100644 --- a/authentik/core/api/propertymappings.py +++ b/authentik/core/api/propertymappings.py @@ -36,11 +36,11 @@ class PropertyMappingTestResultSerializer(PassiveSerializer): class PropertyMappingSerializer(ManagedSerializer, ModelSerializer, MetaNameSerializer): """PropertyMapping Serializer""" - object_type = SerializerMethodField() + component = SerializerMethodField() - def get_object_type(self, obj: PropertyMapping) -> str: - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("propertymapping", "") + def get_component(self, obj: PropertyMapping) -> str: + """Get object's component so that we know how to edit the object""" + return obj.component def validate_expression(self, expression: str) -> str: """Test Syntax""" @@ -56,7 +56,7 @@ class PropertyMappingSerializer(ManagedSerializer, ModelSerializer, MetaNameSeri "managed", "name", "expression", - "object_type", + "component", "verbose_name", "verbose_name_plural", ] diff --git a/authentik/core/api/providers.py b/authentik/core/api/providers.py index 7699b623c9..363f08ef7a 100644 --- a/authentik/core/api/providers.py +++ b/authentik/core/api/providers.py @@ -21,11 +21,11 @@ class ProviderSerializer(ModelSerializer, MetaNameSerializer): assigned_application_slug = ReadOnlyField(source="application.slug") assigned_application_name = ReadOnlyField(source="application.name") - object_type = SerializerMethodField() + component = SerializerMethodField() - def get_object_type(self, obj): # pragma: no cover - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("provider", "") + def get_component(self, obj: Provider): # pragma: no cover + """Get object component so that we know how to edit the object""" + return obj.component class Meta: @@ -35,7 +35,7 @@ class ProviderSerializer(ModelSerializer, MetaNameSerializer): "name", "authorization_flow", "property_mappings", - "object_type", + "component", "assigned_application_slug", "assigned_application_name", "verbose_name", diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index 416ff30d7f..da1070fb4a 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -23,11 +23,11 @@ LOGGER = get_logger() class SourceSerializer(ModelSerializer, MetaNameSerializer): """Source Serializer""" - object_type = SerializerMethodField() + component = SerializerMethodField() - def get_object_type(self, obj): - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("source", "") + def get_component(self, obj: Source): + """Get object component so that we know how to edit the object""" + return obj.component class Meta: @@ -39,7 +39,7 @@ class SourceSerializer(ModelSerializer, MetaNameSerializer): "enabled", "authentication_flow", "enrollment_flow", - "object_type", + "component", "verbose_name", "verbose_name_plural", "policy_engine_mode", diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index d639a7f6b8..8e188487c4 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -23,12 +23,15 @@ LOGGER = get_logger() class StageSerializer(ModelSerializer, MetaNameSerializer): """Stage Serializer""" - object_type = SerializerMethodField() + component = SerializerMethodField() flow_set = FlowSerializer(many=True, required=False) - def get_object_type(self, obj: Stage) -> str: - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("stage", "") + def get_component(self, obj: Stage) -> str: + """Get object type so that we know how to edit the object""" + # pyright: reportGeneralTypeIssues=false + if obj.__class__ == Stage: + return "" + return obj.component class Meta: @@ -36,7 +39,7 @@ class StageSerializer(ModelSerializer, MetaNameSerializer): fields = [ "pk", "name", - "object_type", + "component", "verbose_name", "verbose_name_plural", "flow_set", diff --git a/authentik/flows/tests/test_api.py b/authentik/flows/tests/test_api.py index 07b8eb1b4e..5eaeff42a3 100644 --- a/authentik/flows/tests/test_api.py +++ b/authentik/flows/tests/test_api.py @@ -37,7 +37,7 @@ class TestFlowsAPI(APITestCase): def test_api_serializer(self): """Test that stage serializer returns the correct type""" obj = DummyStage() - self.assertEqual(StageSerializer().get_object_type(obj), "dummy") + self.assertEqual(StageSerializer().get_component(obj), "ak-stage-dummy-form") self.assertEqual(StageSerializer().get_verbose_name(obj), "Dummy Stage") def test_api_viewset(self): diff --git a/authentik/flows/transfer/common.py b/authentik/flows/transfer/common.py index eee22f10e0..f9d7d79fd4 100644 --- a/authentik/flows/transfer/common.py +++ b/authentik/flows/transfer/common.py @@ -22,7 +22,7 @@ def get_attrs(obj: SerializerModel) -> dict[str, Any]: "user", "verbose_name", "verbose_name_plural", - "object_type", + "component", "flow_set", "promptstage_set", ) diff --git a/authentik/outposts/api/outpost_service_connections.py b/authentik/outposts/api/outpost_service_connections.py index 1e3453244d..e19f644fbe 100644 --- a/authentik/outposts/api/outpost_service_connections.py +++ b/authentik/outposts/api/outpost_service_connections.py @@ -31,11 +31,11 @@ from authentik.outposts.models import ( class ServiceConnectionSerializer(ModelSerializer, MetaNameSerializer): """ServiceConnection Serializer""" - object_type = SerializerMethodField() + component = SerializerMethodField() - def get_object_type(self, obj: OutpostServiceConnection) -> str: - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("serviceconnection", "") + def get_component(self, obj: OutpostServiceConnection) -> str: + """Get object component so that we know how to edit the object""" + return obj.component class Meta: @@ -44,7 +44,7 @@ class ServiceConnectionSerializer(ModelSerializer, MetaNameSerializer): "pk", "name", "local", - "object_type", + "component", "verbose_name", "verbose_name_plural", ] diff --git a/authentik/policies/api/policies.py b/authentik/policies/api/policies.py index 195e7e4ada..ab7fdcff2f 100644 --- a/authentik/policies/api/policies.py +++ b/authentik/policies/api/policies.py @@ -33,16 +33,16 @@ class PolicySerializer(ModelSerializer, MetaNameSerializer): _resolve_inheritance: bool - object_type = SerializerMethodField() + component = SerializerMethodField() bound_to = SerializerMethodField() def __init__(self, *args, resolve_inheritance: bool = True, **kwargs): super().__init__(*args, **kwargs) self._resolve_inheritance = resolve_inheritance - def get_object_type(self, obj: Policy) -> str: - """Get object type so that we know which API Endpoint to use to get the full object""" - return obj._meta.object_name.lower().replace("policy", "") + def get_component(self, obj: Policy) -> str: + """Get object component so that we know how to edit the object""" + return obj.component def get_bound_to(self, obj: Policy) -> int: """Return objects policy is bound to""" @@ -65,7 +65,7 @@ class PolicySerializer(ModelSerializer, MetaNameSerializer): "pk", "name", "execution_logging", - "object_type", + "component", "verbose_name", "verbose_name_plural", "bound_to", diff --git a/authentik/policies/dummy/models.py b/authentik/policies/dummy/models.py index 0f892bdfbc..a682d0cc2f 100644 --- a/authentik/policies/dummy/models.py +++ b/authentik/policies/dummy/models.py @@ -30,7 +30,7 @@ class DummyPolicy(Policy): return DummyPolicySerializer @property - def component(self) -> str: + def component(self) -> str: # pragma: no cover return "ak-policy-dummy-form" def passes(self, request: PolicyRequest) -> PolicyResult: diff --git a/authentik/stages/authenticator_validate/migrations/0007_auto_20210403_0927.py b/authentik/stages/authenticator_validate/migrations/0007_auto_20210403_0927.py new file mode 100644 index 0000000000..bebb772aed --- /dev/null +++ b/authentik/stages/authenticator_validate/migrations/0007_auto_20210403_0927.py @@ -0,0 +1,32 @@ +# Generated by Django 3.1.7 on 2021-04-03 09:27 + +import django.contrib.postgres.fields +from django.db import migrations, models + +import authentik.stages.authenticator_validate.models + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_stages_authenticator_validate", "0006_auto_20210301_1757"), + ] + + operations = [ + migrations.AlterField( + model_name="authenticatorvalidatestage", + name="device_classes", + field=django.contrib.postgres.fields.ArrayField( + base_field=models.TextField( + choices=[ + ("static", "Static"), + ("totp", "TOTP"), + ("webauthn", "WebAuthn"), + ] + ), + default=authentik.stages.authenticator_validate.models.default_device_classes, + help_text="Device classes which can be used to authenticate", + size=None, + ), + ), + ] diff --git a/authentik/stages/authenticator_validate/models.py b/authentik/stages/authenticator_validate/models.py index cb1b2cca92..321d51128d 100644 --- a/authentik/stages/authenticator_validate/models.py +++ b/authentik/stages/authenticator_validate/models.py @@ -51,7 +51,7 @@ class AuthenticatorValidateStage(Stage): ) device_classes = ArrayField( - models.TextField(), + models.TextField(choices=DeviceClasses.choices), help_text=_("Device classes which can be used to authenticate"), default=default_device_classes, ) diff --git a/authentik/stages/user_delete/tests.py b/authentik/stages/user_delete/tests.py index 75d876b1c5..48d0a86b7f 100644 --- a/authentik/stages/user_delete/tests.py +++ b/authentik/stages/user_delete/tests.py @@ -73,24 +73,6 @@ class TestUserDeleteStage(TestCase): reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}) ) self.assertEqual(response.status_code, 200) - - def test_user_delete_post(self): - """Test User delete (actual)""" - plan = FlowPlan( - flow_pk=self.flow.pk.hex, stages=[self.stage], markers=[StageMarker()] - ) - plan.context[PLAN_CONTEXT_PENDING_USER] = self.user - session = self.client.session - session[SESSION_KEY_PLAN] = plan - session.save() - - response = self.client.post( - reverse( - "authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug} - ), - {}, - ) - self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, diff --git a/swagger.yaml b/swagger.yaml index 567fb171e0..283d604f23 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -14446,8 +14446,8 @@ definitions: type: string format: uuid uniqueItems: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true assigned_application_slug: @@ -15124,8 +15124,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15274,8 +15274,8 @@ definitions: type: string format: uuid uniqueItems: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true assigned_application_slug: @@ -15606,8 +15606,8 @@ definitions: description: If enabled, use the local connection. Required Docker socket/Kubernetes Integration type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15650,8 +15650,8 @@ definitions: description: If enabled, use the local connection. Required Docker socket/Kubernetes Integration type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15702,8 +15702,8 @@ definitions: description: If enabled, use the local connection. Required Docker socket/Kubernetes Integration type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15736,8 +15736,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15843,8 +15843,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -15889,8 +15889,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16005,8 +16005,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16042,8 +16042,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16087,8 +16087,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16155,8 +16155,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16196,8 +16196,8 @@ definitions: description: When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged. type: boolean - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16296,8 +16296,8 @@ definitions: title: Expression type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16349,8 +16349,8 @@ definitions: title: Expression type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16394,8 +16394,8 @@ definitions: title: Expression type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16443,8 +16443,8 @@ definitions: title: Expression type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16519,8 +16519,8 @@ definitions: type: string format: uuid uniqueItems: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true assigned_application_slug: @@ -16602,8 +16602,8 @@ definitions: type: string format: uuid uniqueItems: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true assigned_application_slug: @@ -16791,8 +16791,8 @@ definitions: type: string format: uuid x-nullable: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -16871,8 +16871,8 @@ definitions: type: string format: uuid x-nullable: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17062,8 +17062,8 @@ definitions: type: string format: uuid x-nullable: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17186,8 +17186,8 @@ definitions: type: string format: uuid x-nullable: true - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17295,8 +17295,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17338,8 +17338,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17381,8 +17381,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17410,7 +17410,10 @@ definitions: items: title: Device classes type: string - minLength: 1 + enum: + - static + - totp + - webauthn configuration_stage: title: Configuration stage description: Stage used to configure Authenticator when user doesn't have @@ -17433,8 +17436,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17472,8 +17475,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17512,8 +17515,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17554,8 +17557,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17584,8 +17587,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17614,8 +17617,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17698,8 +17701,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -17990,8 +17993,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18027,8 +18030,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18135,8 +18138,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18177,8 +18180,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18207,8 +18210,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18243,8 +18246,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: @@ -18273,8 +18276,8 @@ definitions: title: Name type: string minLength: 1 - object_type: - title: Object type + component: + title: Component type: string readOnly: true verbose_name: diff --git a/web/src/pages/flows/BoundStagesList.ts b/web/src/pages/flows/BoundStagesList.ts index 88a4c255ab..991046f46e 100644 --- a/web/src/pages/flows/BoundStagesList.ts +++ b/web/src/pages/flows/BoundStagesList.ts @@ -5,6 +5,7 @@ import { Table, TableColumn } from "../../elements/table/Table"; import "../../elements/forms/DeleteForm"; import "../../elements/forms/ModalForm"; +import "../../elements/forms/ProxyForm"; import "./StageBindingForm"; import "../../elements/Tabs"; import "../../elements/buttons/ModalButton"; @@ -15,7 +16,6 @@ import { until } from "lit-html/directives/until"; import { PAGE_SIZE } from "../../constants"; import { FlowsApi, FlowStageBinding, StagesApi } from "authentik-api"; import { DEFAULT_CONFIG } from "../../api/Config"; -import { AdminURLManager } from "../../api/legacy"; import { ifDefined } from "lit-html/directives/if-defined"; @customElement("ak-bound-stages-list") @@ -49,12 +49,24 @@ export class BoundStagesList extends Table { html`${item.stageObj?.name}`, html`${item.stageObj?.verboseName}`, html` - - + + + ${gettext("Update")} + + + ${gettext(`Update ${item.stageObj?.verboseName}`)} + + + + + ${gettext("Update")} diff --git a/web/src/pages/outposts/ServiceConnectionListPage.ts b/web/src/pages/outposts/ServiceConnectionListPage.ts index 2002f54afd..937638c48b 100644 --- a/web/src/pages/outposts/ServiceConnectionListPage.ts +++ b/web/src/pages/outposts/ServiceConnectionListPage.ts @@ -84,11 +84,7 @@ export class OutpostServiceConnectionListPage extends TablePage + type=${ifDefined(item.component)}> + `; } else if (item.group) { return html` diff --git a/web/src/pages/policies/PolicyListPage.ts b/web/src/pages/policies/PolicyListPage.ts index 219b7dd75e..b989e61c9e 100644 --- a/web/src/pages/policies/PolicyListPage.ts +++ b/web/src/pages/policies/PolicyListPage.ts @@ -84,16 +84,7 @@ export class PolicyListPage extends TablePage { .args=${{ "policyUUID": item.pk }} - type=${ifDefined(item.objectType)} - .typeMap=${{ - "dummy": "ak-policy-dummy-form", - "eventmatcher": "ak-policy-event-matcher-form", - "expression": "ak-policy-expression-form", - "passwordexpiry": "ak-policy-password-expiry-form", - "haveibeenpwend": "ak-policy-hibp-form", - "password": "ak-policy-password-form", - "reputation": "ak-policy-reputation-form", - }}> + type=${ifDefined(item.component)}> + `; }); }), html``)} diff --git a/web/src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts b/web/src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts index 30260c02aa..4034be8514 100644 --- a/web/src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts +++ b/web/src/pages/stages/authenticator_validate/AuthenticatorValidateStageForm.ts @@ -1,4 +1,4 @@ -import { AuthenticatorValidateStage, AuthenticatorValidateStageNotConfiguredActionEnum, StagesApi } from "authentik-api"; +import { AuthenticatorValidateStage, AuthenticatorValidateStageNotConfiguredActionEnum, AuthenticatorValidateStageDeviceClassesEnum, StagesApi } from "authentik-api"; import { gettext } from "django"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; @@ -7,7 +7,6 @@ import { Form } from "../../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/FormGroup"; -import { DeviceClasses } from "authentik-api/dist/src/flows/stages/authenticator_validate/AuthenticatorValidateStage"; import { until } from "lit-html/directives/until"; @customElement("ak-stage-authenticator-validate-form") @@ -49,7 +48,7 @@ export class AuthenticatorValidateStageForm extends Form { return field === isField; }).length > 0; @@ -96,13 +95,13 @@ export class AuthenticatorValidateStageForm extends Form @@ -120,8 +119,8 @@ export class AuthenticatorValidateStageForm extends Form { return stages.results.map(stage => { - let selected = this.stage?.configurationStage === stage.pk; - return html``; + const selected = this.stage?.configurationStage === stage.pk; + return html``; }); }))} diff --git a/web/src/pages/stages/identification/IdentificationStageForm.ts b/web/src/pages/stages/identification/IdentificationStageForm.ts index 9b0fadadb8..b5dc9fca83 100644 --- a/web/src/pages/stages/identification/IdentificationStageForm.ts +++ b/web/src/pages/stages/identification/IdentificationStageForm.ts @@ -106,7 +106,7 @@ export class IdentificationStageForm extends Form { designation: FlowDesignationEnum.Enrollment, }).then(flows => { return flows.results.map(flow => { - let selected = this.stage?.enrollmentFlow === flow.pk; + const selected = this.stage?.enrollmentFlow === flow.pk; return html``; }); }))} @@ -123,7 +123,7 @@ export class IdentificationStageForm extends Form { designation: FlowDesignationEnum.Recovery, }).then(flows => { return flows.results.map(flow => { - let selected = this.stage?.recoveryFlow === flow.pk; + const selected = this.stage?.recoveryFlow === flow.pk; return html``; }); }))}