Skip to content

Commit ed8be0d

Browse files
committed
Added configuration option to disable referrals
nginxinc/nginx-ldap-auth@f56178b
1 parent af901c8 commit ed8be0d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

root/app/nginx-ldap-auth-daemon.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class LDAPAuthHandler(AuthHandler):
172172
'realm': ('X-Ldap-Realm', 'Restricted'),
173173
'url': ('X-Ldap-URL', None),
174174
'starttls': ('X-Ldap-Starttls', 'false'),
175+
'disable_referrals': ('X-Ldap-DisableReferrals', 'false'),
175176
'basedn': ('X-Ldap-BaseDN', None),
176177
'template': ('X-Ldap-Template', '(cn=%(username)s)'),
177178
'binddn': ('X-Ldap-BindDN', ''),
@@ -233,9 +234,9 @@ def do_GET(self):
233234
if ctx['starttls'] == 'true':
234235
ldap_obj.start_tls_s()
235236

236-
# See http://www.python-ldap.org/faq.shtml
237-
# uncomment, if required
238-
# ldap_obj.set_option(ldap.OPT_REFERRALS, 0)
237+
# See https://www.python-ldap.org/en/latest/faq.html
238+
if ctx['disable_referrals'] == 'true':
239+
ldap_obj.set_option(ldap.OPT_REFERRALS, 0)
239240

240241
ctx['action'] = 'binding as search user'
241242
ldap_obj.bind_s(ctx['binddn'], ctx['bindpasswd'], ldap.AUTH_SIMPLE)
@@ -328,6 +329,7 @@ def exit_handler(signal, frame):
328329
'realm': ('X-Ldap-Realm', args.realm),
329330
'url': ('X-Ldap-URL', args.url),
330331
'starttls': ('X-Ldap-Starttls', args.starttls),
332+
'disable_referrals': ('X-Ldap-DisableReferrals', args.disable_referrals),
331333
'basedn': ('X-Ldap-BaseDN', args.basedn),
332334
'template': ('X-Ldap-Template', args.filter),
333335
'binddn': ('X-Ldap-BindDN', args.binddn),

0 commit comments

Comments
 (0)