mirror of
https://github.com/ansible/awx.git
synced 2026-07-28 16:39:56 -02:30
enforce a sane default OPT_NETWORK_TIMEOUT for LDAP connections
see: #5208
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
import logging
|
||||
import uuid
|
||||
|
||||
import ldap
|
||||
|
||||
# Django
|
||||
from django.dispatch import receiver
|
||||
from django.contrib.auth.models import User
|
||||
@@ -38,6 +40,16 @@ class LDAPSettings(BaseLDAPSettings):
|
||||
'TEAM_MAP': {},
|
||||
}.items())
|
||||
|
||||
def __init__(self, prefix='AUTH_LDAP_', defaults={}):
|
||||
super(LDAPSettings, self).__init__(prefix, defaults)
|
||||
|
||||
# If a DB-backed setting is specified that wipes out the
|
||||
# OPT_NETWORK_TIMEOUT, fall back to a sane default
|
||||
if ldap.OPT_NETWORK_TIMEOUT not in getattr(self, 'CONNECTION_OPTIONS', {}):
|
||||
options = getattr(self, 'CONNECTION_OPTIONS', {})
|
||||
options[ldap.OPT_NETWORK_TIMEOUT] = 30
|
||||
self.CONNECTION_OPTIONS = options
|
||||
|
||||
|
||||
class LDAPBackend(BaseLDAPBackend):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user