File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 11django-python3-ldap
22===================
33
4- **django-python3-ldap ** provides a Django LDAP user authentication backend.
4+ **django-python3-ldap ** provides a Django LDAP user authentication backend. Python 3.6+ is required.
55
66
77Features
Original file line number Diff line number Diff line change 11"""
22Settings used by django-python3.
33"""
4+ from ssl import PROTOCOL_TLS
45
56from django .conf import settings
67
@@ -45,7 +46,7 @@ def __init__(self, settings):
4546
4647 LDAP_AUTH_TLS_VERSION = LazySetting (
4748 name = "LDAP_AUTH_TLS_VERSION" ,
48- default = "SSLv3" ,
49+ default = PROTOCOL_TLS ,
4950 )
5051
5152 LDAP_AUTH_SEARCH_BASE = LazySetting (
Original file line number Diff line number Diff line change @@ -156,29 +156,32 @@ def connection(**kwargs):
156156 if not isinstance (auth_url , list ):
157157 auth_url = [auth_url ]
158158 for u in auth_url :
159+ # Include SSL / TLS, if requested.
160+ server_args = {
161+ "allowed_referral_hosts" : [("*" , True )],
162+ "get_info" : ldap3 .NONE ,
163+ "connect_timeout" : settings .LDAP_AUTH_CONNECT_TIMEOUT ,
164+ }
165+ if settings .LDAP_AUTH_USE_TLS :
166+ server_args ["tls" ] = ldap3 .Tls (
167+ ciphers = "ALL" ,
168+ version = settings .LDAP_AUTH_TLS_VERSION ,
169+ )
159170 server_pool .add (
160171 ldap3 .Server (
161172 u ,
162- allowed_referral_hosts = [("*" , True )],
163- get_info = ldap3 .NONE ,
164- connect_timeout = settings .LDAP_AUTH_CONNECT_TIMEOUT ,
173+ ** server_args ,
165174 )
166175 )
167176 # Connect.
168177 try :
169- # Include SSL / TLS, if requested.
170178 connection_args = {
171179 "user" : username ,
172180 "password" : password ,
173181 "auto_bind" : False ,
174182 "raise_exceptions" : True ,
175183 "receive_timeout" : settings .LDAP_AUTH_RECEIVE_TIMEOUT ,
176184 }
177- if settings .LDAP_AUTH_USE_TLS :
178- connection_args ["tls" ] = ldap3 .Tls (
179- ciphers = 'ALL' ,
180- version = settings .LDAP_AUTH_TLS_VERSION ,
181- )
182185 c = ldap3 .Connection (
183186 server_pool ,
184187 ** connection_args ,
You can’t perform that action at this time.
0 commit comments