mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
LDAP setting fields validation updates.
This commit is contained in:
parent
430d4bc28e
commit
2c69d433e9
@ -216,7 +216,7 @@ register(
|
||||
'mapped into an Tower organization (as defined in the '
|
||||
'AUTH_LDAP_ORGANIZATION_MAP setting). If multiple search queries '
|
||||
'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_slug='ldap',
|
||||
placeholder=(
|
||||
|
||||
@ -269,7 +269,18 @@ class LDAPSearchUnionField(fields.ListField):
|
||||
if len(data) == 3 and isinstance(data[0], basestring):
|
||||
return self.ldap_search_field_class().run_validation(data)
|
||||
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):
|
||||
|
||||
@ -32,7 +32,8 @@ def validate_ldap_dn_with_user(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)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user