mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 15:06:02 -03:30
Merge pull request #6837 from jangsutsr/6107_ldap_setting_field_validator_updates
LDAP setting fields validation updates.
This commit is contained in:
@@ -216,7 +216,7 @@ register(
|
|||||||
'mapped into an Tower organization (as defined in the '
|
'mapped into an Tower organization (as defined in the '
|
||||||
'AUTH_LDAP_ORGANIZATION_MAP setting). If multiple search queries '
|
'AUTH_LDAP_ORGANIZATION_MAP setting). If multiple search queries '
|
||||||
'need to be supported use of "LDAPUnion" is possible. See '
|
'need to be supported use of "LDAPUnion" is possible. See '
|
||||||
'python-ldap documentation as linked at the top of this section.'),
|
'Tower documentation for details.'),
|
||||||
category=_('LDAP'),
|
category=_('LDAP'),
|
||||||
category_slug='ldap',
|
category_slug='ldap',
|
||||||
placeholder=(
|
placeholder=(
|
||||||
|
|||||||
@@ -269,7 +269,18 @@ class LDAPSearchUnionField(fields.ListField):
|
|||||||
if len(data) == 3 and isinstance(data[0], basestring):
|
if len(data) == 3 and isinstance(data[0], basestring):
|
||||||
return self.ldap_search_field_class().run_validation(data)
|
return self.ldap_search_field_class().run_validation(data)
|
||||||
else:
|
else:
|
||||||
return LDAPSearchUnion(*[self.ldap_search_field_class().run_validation(x) for x in data])
|
search_args = []
|
||||||
|
for i in range(len(data)):
|
||||||
|
if not isinstance(data[i], list):
|
||||||
|
raise ValidationError('In order to ultilize LDAP Union, input element No. %d'
|
||||||
|
' should be a search query array.' % (i + 1))
|
||||||
|
try:
|
||||||
|
search_args.append(self.ldap_search_field_class().run_validation(data[i]))
|
||||||
|
except Exception as e:
|
||||||
|
if hasattr(e, 'detail') and isinstance(e.detail, list):
|
||||||
|
e.detail.insert(0, "Error parsing LDAP Union element No. %d:" % (i + 1))
|
||||||
|
raise e
|
||||||
|
return LDAPSearchUnion(*search_args)
|
||||||
|
|
||||||
|
|
||||||
class LDAPUserAttrMapField(fields.DictField):
|
class LDAPUserAttrMapField(fields.DictField):
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ def validate_ldap_dn_with_user(value):
|
|||||||
|
|
||||||
|
|
||||||
def validate_ldap_bind_dn(value):
|
def validate_ldap_bind_dn(value):
|
||||||
if not re.match(r'^[A-Za-z][A-Za-z0-9._-]*?\\[A-Za-z0-9 ._-]+?$', value.strip()):
|
if not re.match(r'^[A-Za-z][A-Za-z0-9._-]*?\\[A-Za-z0-9 ._-]+?$', value.strip()) and \
|
||||||
|
not re.match(r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$', value.strip()):
|
||||||
validate_ldap_dn(value)
|
validate_ldap_dn(value)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user