From 5cad59a9f8dd2cac81e4bf11ba0143d5315f9e19 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 9 May 2021 00:07:34 +0200 Subject: [PATCH] providers/proxy: fix being able to set empty internal_host Signed-off-by: Jens Langhammer --- authentik/providers/proxy/api.py | 14 ++++++++++++++ authentik/sources/ldap/sync/base.py | 2 +- web/src/pages/providers/ProviderListPage.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/authentik/providers/proxy/api.py b/authentik/providers/proxy/api.py index cac707448..7b6c7bf76 100644 --- a/authentik/providers/proxy/api.py +++ b/authentik/providers/proxy/api.py @@ -1,5 +1,8 @@ """ProxyProvider API Views""" +from typing import Any + from drf_yasg.utils import swagger_serializer_method +from rest_framework.exceptions import ValidationError from rest_framework.fields import CharField, ListField, SerializerMethodField from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet @@ -30,6 +33,17 @@ class OpenIDConnectConfigurationSerializer(PassiveSerializer): class ProxyProviderSerializer(ProviderSerializer): """ProxyProvider Serializer""" + def validate(self, attrs) -> dict[Any, str]: + """Check that internal_host is set when forward_auth_mode is disabled""" + if ( + not attrs.get("forward_auth_mode", False) + and attrs.get("internal_host", "") == "" + ): + raise ValidationError( + "Internal host cannot be empty when forward auth is disabled." + ) + return attrs + def create(self, validated_data): instance: ProxyProvider = super().create(validated_data) instance.set_oauth_defaults() diff --git a/authentik/sources/ldap/sync/base.py b/authentik/sources/ldap/sync/base.py index 3463a93e6..b5c4d27ee 100644 --- a/authentik/sources/ldap/sync/base.py +++ b/authentik/sources/ldap/sync/base.py @@ -19,7 +19,7 @@ class BaseLDAPSynchronizer: def __init__(self, source: LDAPSource): self._source = source - self._logger = get_logger().bind(source=source) + self._logger = get_logger().bind(source=source, syncer=self.__class__.__name__) @property def base_dn_users(self) -> str: diff --git a/web/src/pages/providers/ProviderListPage.ts b/web/src/pages/providers/ProviderListPage.ts index 28fad5047..cf1d56281 100644 --- a/web/src/pages/providers/ProviderListPage.ts +++ b/web/src/pages/providers/ProviderListPage.ts @@ -89,7 +89,7 @@ export class ProviderListPage extends TablePage { { return new ProvidersApi(DEFAULT_CONFIG).providersAllDelete({ id: item.pk || 0