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 1337793
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 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,13 @@ 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 = (

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
self.env["ir.config_parameter"]
.sudo()
.get_param("auth_ldap.disable_chase_ref")
)
if str2bool(ldap_chase_ref_disabled):
connection.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)

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

View check run for this annotation

Codecov / codecov/patch

auth_ldaps/models/res_company_ldap.py#L42

Added line #L42 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 44 in auth_ldaps/models/res_company_ldap.py

View check run for this annotation

Codecov / codecov/patch

auth_ldaps/models/res_company_ldap.py#L44

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

0 comments on commit 1337793

Please sign in to comment.