Skip to content

Commit

Permalink
[IMP] auth_ldaps: Allow disabling LDAP ref-chasing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanc-me authored and rven committed Aug 1, 2024
1 parent 4710036 commit e8f06e7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions auth_ldaps/models/res_company_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import ldap

from odoo import fields, models
from odoo.tools.misc import str2bool

_logger = logging.getLogger(__name__)

Expand All @@ -32,6 +33,9 @@ def _connect(self, conf):
if conf["is_ssl"]:
uri = "ldaps://%s:%d" % (conf["ldap_server"], conf["ldap_server_port"])
connection = ldap.initialize(uri)
ldap_chase_ref_disabled = self.env['ir.config_parameter'].sudo().get_param('auth_ldap.disable_chase_ref')

Check warning on line 36 in auth_ldaps/models/res_company_ldap.py

View check run for this annotation

Codecov / codecov/patch

auth_ldaps/models/res_company_ldap.py#L34-L36

Added lines #L34 - L36 were not covered by tests
if str2bool(ldap_chase_ref_disabled):
connection.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)

Check warning on line 38 in auth_ldaps/models/res_company_ldap.py

View check run for this annotation

Codecov / codecov/patch

auth_ldaps/models/res_company_ldap.py#L38

Added line #L38 was not covered by tests
if conf["skip_cert_validation"]:
connection.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_ALLOW)

Check warning on line 40 in auth_ldaps/models/res_company_ldap.py

View check run for this annotation

Codecov / codecov/patch

auth_ldaps/models/res_company_ldap.py#L40

Added line #L40 was not covered by tests
# this creates a new tls context, which is required to apply
Expand Down

0 comments on commit e8f06e7

Please sign in to comment.