mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
truncate user first/last name if it exceeds 30 chars on LDAP auth
This commit is contained in:
parent
c0c358b640
commit
d3dc126d45
@ -361,6 +361,16 @@ def on_populate_user(sender, **kwargs):
|
|||||||
# checking membership.
|
# checking membership.
|
||||||
ldap_user._get_groups().get_group_dns()
|
ldap_user._get_groups().get_group_dns()
|
||||||
|
|
||||||
|
# If the LDAP user has a first or last name > $maxlen chars, truncate it
|
||||||
|
for field in ('first_name', 'last_name'):
|
||||||
|
max_len = User._meta.get_field(field).max_length
|
||||||
|
field_len = len(getattr(user, field))
|
||||||
|
if field_len > max_len:
|
||||||
|
setattr(user, field, getattr(user, field)[:max_len])
|
||||||
|
logger.warn(six.text_type(
|
||||||
|
'LDAP user {} has {} > max {} characters'
|
||||||
|
).format(user.username, field, max_len))
|
||||||
|
|
||||||
# Update organization membership based on group memberships.
|
# Update organization membership based on group memberships.
|
||||||
org_map = getattr(backend.settings, 'ORGANIZATION_MAP', {})
|
org_map = getattr(backend.settings, 'ORGANIZATION_MAP', {})
|
||||||
for org_name, org_opts in org_map.items():
|
for org_name, org_opts in org_map.items():
|
||||||
|
Loading…
Reference in New Issue
Block a user