This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/channels/in_ldap/api.py

53 lines
1.5 KiB
Python
Raw Normal View History

"""Inlet API Views"""
2019-10-28 16:40:57 +00:00
from rest_framework.serializers import ModelSerializer
from rest_framework.viewsets import ModelViewSet
from passbook.admin.forms.inlet import INLET_SERIALIZER_FIELDS
from passbook.channels.in_ldap.models import LDAPInlet, LDAPPropertyMapping
2019-10-28 16:40:57 +00:00
class LDAPInletSerializer(ModelSerializer):
"""LDAP Inlet Serializer"""
2019-10-28 16:40:57 +00:00
class Meta:
model = LDAPInlet
fields = INLET_SERIALIZER_FIELDS + [
2019-12-31 11:51:16 +00:00
"server_uri",
"bind_cn",
"bind_password",
"start_tls",
"base_dn",
"additional_user_dn",
"additional_group_dn",
"user_object_filter",
"group_object_filter",
"user_group_membership_field",
"object_uniqueness_field",
"sync_groups",
"sync_parent_group",
"property_mappings",
2019-10-28 16:40:57 +00:00
]
2019-12-31 11:51:16 +00:00
extra_kwargs = {"bind_password": {"write_only": True}}
2019-10-28 16:40:57 +00:00
2019-10-28 16:55:36 +00:00
class LDAPPropertyMappingSerializer(ModelSerializer):
"""LDAP PropertyMapping Serializer"""
class Meta:
model = LDAPPropertyMapping
fields = ["pk", "name", "expression", "object_field"]
2019-10-28 16:55:36 +00:00
class LDAPInletViewSet(ModelViewSet):
"""LDAP Inlet Viewset"""
2019-10-28 16:40:57 +00:00
queryset = LDAPInlet.objects.all()
serializer_class = LDAPInletSerializer
2019-10-28 16:55:36 +00:00
class LDAPPropertyMappingViewSet(ModelViewSet):
"""LDAP PropertyMapping Viewset"""
queryset = LDAPPropertyMapping.objects.all()
serializer_class = LDAPPropertyMappingSerializer