2018-11-26 17:22:38 +00:00
|
|
|
"""passbook LDAP Forms"""
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
from django import forms
|
2019-03-10 17:34:09 +00:00
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
2019-02-21 15:06:57 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2018-11-11 12:41:48 +00:00
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
from passbook.admin.forms.source import SOURCE_FORM_FIELDS
|
2019-10-11 10:53:48 +00:00
|
|
|
from passbook.sources.ldap.models import LDAPPropertyMapping, LDAPSource
|
2018-11-11 12:41:48 +00:00
|
|
|
|
|
|
|
|
2018-11-26 17:22:38 +00:00
|
|
|
class LDAPSourceForm(forms.ModelForm):
|
|
|
|
"""LDAPSource Form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = LDAPSource
|
2019-10-10 15:36:09 +00:00
|
|
|
fields = SOURCE_FORM_FIELDS + [
|
|
|
|
'server_uri',
|
|
|
|
'bind_cn',
|
|
|
|
'bind_password',
|
|
|
|
'start_tls',
|
|
|
|
'base_dn',
|
|
|
|
'additional_user_dn',
|
|
|
|
'additional_group_dn',
|
|
|
|
'user_object_filter',
|
|
|
|
'group_object_filter',
|
|
|
|
'sync_groups',
|
|
|
|
'sync_parent_group',
|
2019-10-11 10:53:48 +00:00
|
|
|
'property_mappings',
|
2019-10-10 15:36:09 +00:00
|
|
|
]
|
2018-11-26 21:09:04 +00:00
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'server_uri': forms.TextInput(),
|
|
|
|
'bind_cn': forms.TextInput(),
|
2019-10-10 15:36:09 +00:00
|
|
|
'bind_password': forms.PasswordInput(),
|
2018-11-26 21:09:04 +00:00
|
|
|
'base_dn': forms.TextInput(),
|
2019-10-10 15:36:09 +00:00
|
|
|
'additional_user_dn': forms.TextInput(),
|
|
|
|
'additional_group_dn': forms.TextInput(),
|
|
|
|
'user_object_filter': forms.TextInput(),
|
|
|
|
'group_object_filter': forms.TextInput(),
|
2019-10-11 10:53:48 +00:00
|
|
|
'policies': FilteredSelectMultiple(_('policies'), False),
|
|
|
|
'property_mappings': FilteredSelectMultiple(_('Property Mappings'), False)
|
2018-11-26 21:09:04 +00:00
|
|
|
}
|
2019-02-21 15:06:57 +00:00
|
|
|
labels = {
|
|
|
|
'server_uri': _('Server URI'),
|
|
|
|
'bind_cn': _('Bind CN'),
|
2019-10-10 15:36:09 +00:00
|
|
|
'start_tls': _('Enable Start TLS'),
|
2019-02-21 15:06:57 +00:00
|
|
|
'base_dn': _('Base DN'),
|
2019-10-10 15:36:09 +00:00
|
|
|
'additional_user_dn': _('Addition User DN'),
|
|
|
|
'additional_group_dn': _('Addition Group DN'),
|
2019-03-10 18:45:16 +00:00
|
|
|
}
|
2019-10-11 10:53:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LDAPPropertyMappingForm(forms.ModelForm):
|
|
|
|
"""LDAP Property Mapping form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = LDAPPropertyMapping
|
|
|
|
fields = ['name', 'ldap_property', 'object_field']
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'ldap_property': forms.TextInput(),
|
|
|
|
'object_field': forms.TextInput(),
|
|
|
|
}
|