From 17de0ff24e527eb78cbe4dcd449d3e6261e913a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Apr 2021 10:54:38 +0200 Subject: [PATCH] build(deps): bump django from 3.1.7 to 3.2 (#707) * build(deps): bump django from 3.1.7 to 3.2 Bumps [django](https://github.com/django/django) from 3.1.7 to 3.2. - [Release notes](https://github.com/django/django/releases) - [Commits](https://github.com/django/django/compare/3.1.7...3.2) Signed-off-by: dependabot[bot] * root: set DEFAULT_AUTO_FIELD and remove full app config paths Signed-off-by: Jens Langhammer * *: check parent class for component and serializer on abstract classes Signed-off-by: Jens Langhammer Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer --- Pipfile.lock | 6 +- authentik/core/api/sources.py | 7 +- authentik/lib/tests/test_serializer_model.py | 8 +- authentik/root/settings.py | 80 ++++++++++---------- authentik/sources/ldap/signals.py | 2 +- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index 539c41be8..958a0b2fa 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -312,11 +312,11 @@ }, "django": { "hashes": [ - "sha256:32ce792ee9b6a0cbbec340123e229ac9f765dff8c2a4ae9247a14b2ba3a365a7", - "sha256:baf099db36ad31f970775d0be5587cc58a6256a6771a44eb795b554d45f211b8" + "sha256:0604e84c4fb698a5e53e5857b5aea945b2f19a18f25f10b8748dbdf935788927", + "sha256:21f0f9643722675976004eb683c55d33c05486f94506672df3d6a141546f389d" ], "index": "pypi", - "version": "==3.1.7" + "version": "==3.2" }, "django-dbbackup": { "hashes": [ diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index a113d686f..0fb4bff31 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -67,12 +67,17 @@ class SourceViewSet( data = [] for subclass in all_subclasses(self.queryset.model): subclass: Source + component = "" + if subclass._meta.abstract: + component = subclass.__bases__[0]().component + else: + component = subclass().component # pyright: reportGeneralTypeIssues=false data.append( { "name": subclass._meta.verbose_name, "description": subclass.__doc__, - "component": subclass().component, + "component": component, } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/lib/tests/test_serializer_model.py b/authentik/lib/tests/test_serializer_model.py index 9075a2a03..d47787745 100644 --- a/authentik/lib/tests/test_serializer_model.py +++ b/authentik/lib/tests/test_serializer_model.py @@ -17,9 +17,13 @@ def model_tester_factory(test_model: Type[Stage]) -> Callable: """Test a form""" def tester(self: TestModels): - model_inst = test_model() try: - self.assertTrue(issubclass(model_inst.serializer, BaseSerializer)) + model_class = None + if test_model._meta.abstract: + model_class = test_model.__bases__[0]() + else: + model_class = test_model() + self.assertTrue(issubclass(model_class.serializer, BaseSerializer)) except NotImplementedError: pass diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 584a6385c..7962fc997 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -76,6 +76,8 @@ AUTHENTICATION_BACKENDS = [ "guardian.backends.ObjectPermissionBackend", ] +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" + # Application definition INSTALLED_APPS = [ "django.contrib.auth", @@ -84,45 +86,45 @@ INSTALLED_APPS = [ "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.humanize", - "authentik.admin.apps.AuthentikAdminConfig", - "authentik.api.apps.AuthentikAPIConfig", - "authentik.events.apps.AuthentikEventsConfig", - "authentik.crypto.apps.AuthentikCryptoConfig", - "authentik.flows.apps.AuthentikFlowsConfig", - "authentik.outposts.apps.AuthentikOutpostConfig", - "authentik.lib.apps.AuthentikLibConfig", - "authentik.policies.apps.AuthentikPoliciesConfig", - "authentik.policies.dummy.apps.AuthentikPolicyDummyConfig", - "authentik.policies.event_matcher.apps.AuthentikPoliciesEventMatcherConfig", - "authentik.policies.expiry.apps.AuthentikPolicyExpiryConfig", - "authentik.policies.expression.apps.AuthentikPolicyExpressionConfig", - "authentik.policies.hibp.apps.AuthentikPolicyHIBPConfig", - "authentik.policies.password.apps.AuthentikPoliciesPasswordConfig", - "authentik.policies.reputation.apps.AuthentikPolicyReputationConfig", - "authentik.providers.proxy.apps.AuthentikProviderProxyConfig", - "authentik.providers.oauth2.apps.AuthentikProviderOAuth2Config", - "authentik.providers.saml.apps.AuthentikProviderSAMLConfig", - "authentik.recovery.apps.AuthentikRecoveryConfig", - "authentik.sources.ldap.apps.AuthentikSourceLDAPConfig", - "authentik.sources.oauth.apps.AuthentikSourceOAuthConfig", - "authentik.sources.saml.apps.AuthentikSourceSAMLConfig", - "authentik.stages.authenticator_static.apps.AuthentikStageAuthenticatorStaticConfig", - "authentik.stages.authenticator_totp.apps.AuthentikStageAuthenticatorTOTPConfig", - "authentik.stages.authenticator_validate.apps.AuthentikStageAuthenticatorValidateConfig", - "authentik.stages.authenticator_webauthn.apps.AuthentikStageAuthenticatorWebAuthnConfig", - "authentik.stages.captcha.apps.AuthentikStageCaptchaConfig", - "authentik.stages.consent.apps.AuthentikStageConsentConfig", - "authentik.stages.deny.apps.AuthentikStageDenyConfig", - "authentik.stages.dummy.apps.AuthentikStageDummyConfig", - "authentik.stages.email.apps.AuthentikStageEmailConfig", - "authentik.stages.identification.apps.AuthentikStageIdentificationConfig", - "authentik.stages.invitation.apps.AuthentikStageUserInvitationConfig", - "authentik.stages.password.apps.AuthentikStagePasswordConfig", - "authentik.stages.prompt.apps.AuthentikStagePromptConfig", - "authentik.stages.user_delete.apps.AuthentikStageUserDeleteConfig", - "authentik.stages.user_login.apps.AuthentikStageUserLoginConfig", - "authentik.stages.user_logout.apps.AuthentikStageUserLogoutConfig", - "authentik.stages.user_write.apps.AuthentikStageUserWriteConfig", + "authentik.admin", + "authentik.api", + "authentik.events", + "authentik.crypto", + "authentik.flows", + "authentik.outposts", + "authentik.lib", + "authentik.policies", + "authentik.policies.dummy", + "authentik.policies.event_matcher", + "authentik.policies.expiry", + "authentik.policies.expression", + "authentik.policies.hibp", + "authentik.policies.password", + "authentik.policies.reputation", + "authentik.providers.proxy", + "authentik.providers.oauth2", + "authentik.providers.saml", + "authentik.recovery", + "authentik.sources.ldap", + "authentik.sources.oauth", + "authentik.sources.saml", + "authentik.stages.authenticator_static", + "authentik.stages.authenticator_totp", + "authentik.stages.authenticator_validate", + "authentik.stages.authenticator_webauthn", + "authentik.stages.captcha", + "authentik.stages.consent", + "authentik.stages.deny", + "authentik.stages.dummy", + "authentik.stages.email", + "authentik.stages.identification", + "authentik.stages.invitation", + "authentik.stages.password", + "authentik.stages.prompt", + "authentik.stages.user_delete", + "authentik.stages.user_login", + "authentik.stages.user_logout", + "authentik.stages.user_write", "rest_framework", "django_filters", "drf_yasg", diff --git a/authentik/sources/ldap/signals.py b/authentik/sources/ldap/signals.py index 08d94c07a..1802b8906 100644 --- a/authentik/sources/ldap/signals.py +++ b/authentik/sources/ldap/signals.py @@ -1,11 +1,11 @@ """authentik ldap source signals""" from typing import Any -from django.core.exceptions import ValidationError from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.translation import gettext_lazy as _ from ldap3.core.exceptions import LDAPException +from rest_framework.serializers import ValidationError from authentik.core.models import User from authentik.core.signals import password_changed