61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""authentik LDAP Forms"""
|
|
|
|
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from authentik.sources.ldap.models import LDAPPropertyMapping, LDAPSource
|
|
|
|
|
|
class LDAPSourceForm(forms.ModelForm):
|
|
"""LDAPSource Form"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields["property_mappings"].queryset = LDAPPropertyMapping.objects.all()
|
|
self.fields[
|
|
"property_mappings_group"
|
|
].queryset = LDAPPropertyMapping.objects.all()
|
|
|
|
class Meta:
|
|
|
|
model = LDAPSource
|
|
fields = [
|
|
# we don't use all common fields, as we don't use flows for this
|
|
"name",
|
|
"slug",
|
|
"enabled",
|
|
"policy_engine_mode",
|
|
# -- start of our custom fields
|
|
"server_uri",
|
|
"start_tls",
|
|
"bind_cn",
|
|
"bind_password",
|
|
"base_dn",
|
|
"sync_users",
|
|
"sync_users_password",
|
|
"sync_groups",
|
|
"property_mappings",
|
|
"property_mappings_group",
|
|
"additional_user_dn",
|
|
"additional_group_dn",
|
|
"user_object_filter",
|
|
"group_object_filter",
|
|
"group_membership_field",
|
|
"object_uniqueness_field",
|
|
"sync_parent_group",
|
|
]
|
|
labels = {"property_mappings_group": _("Group property mappings")}
|
|
widgets = {
|
|
"name": forms.TextInput(),
|
|
"server_uri": forms.TextInput(),
|
|
"bind_cn": forms.TextInput(),
|
|
"bind_password": forms.TextInput(),
|
|
"base_dn": forms.TextInput(),
|
|
"additional_user_dn": forms.TextInput(),
|
|
"additional_group_dn": forms.TextInput(),
|
|
"user_object_filter": forms.TextInput(),
|
|
"group_object_filter": forms.TextInput(),
|
|
"group_membership_field": forms.TextInput(),
|
|
"object_uniqueness_field": forms.TextInput(),
|
|
}
|