providers/proxy: fix being able to set empty internal_host
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
5ac6a6910e
commit
5cad59a9f8
|
@ -1,5 +1,8 @@
|
||||||
"""ProxyProvider API Views"""
|
"""ProxyProvider API Views"""
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from drf_yasg.utils import swagger_serializer_method
|
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.fields import CharField, ListField, SerializerMethodField
|
||||||
from rest_framework.serializers import ModelSerializer
|
from rest_framework.serializers import ModelSerializer
|
||||||
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
|
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet
|
||||||
|
@ -30,6 +33,17 @@ class OpenIDConnectConfigurationSerializer(PassiveSerializer):
|
||||||
class ProxyProviderSerializer(ProviderSerializer):
|
class ProxyProviderSerializer(ProviderSerializer):
|
||||||
"""ProxyProvider Serializer"""
|
"""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):
|
def create(self, validated_data):
|
||||||
instance: ProxyProvider = super().create(validated_data)
|
instance: ProxyProvider = super().create(validated_data)
|
||||||
instance.set_oauth_defaults()
|
instance.set_oauth_defaults()
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BaseLDAPSynchronizer:
|
||||||
|
|
||||||
def __init__(self, source: LDAPSource):
|
def __init__(self, source: LDAPSource):
|
||||||
self._source = source
|
self._source = source
|
||||||
self._logger = get_logger().bind(source=source)
|
self._logger = get_logger().bind(source=source, syncer=self.__class__.__name__)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def base_dn_users(self) -> str:
|
def base_dn_users(self) -> str:
|
||||||
|
|
|
@ -89,7 +89,7 @@ export class ProviderListPage extends TablePage<Provider> {
|
||||||
</ak-forms-modal>
|
</ak-forms-modal>
|
||||||
<ak-forms-delete
|
<ak-forms-delete
|
||||||
.obj=${item}
|
.obj=${item}
|
||||||
objectLabel=${t`Source`}
|
objectLabel=${t`Provider`}
|
||||||
.delete=${() => {
|
.delete=${() => {
|
||||||
return new ProvidersApi(DEFAULT_CONFIG).providersAllDelete({
|
return new ProvidersApi(DEFAULT_CONFIG).providersAllDelete({
|
||||||
id: item.pk || 0
|
id: item.pk || 0
|
||||||
|
|
Reference in New Issue