Skip to content

feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients - #665

Merged
LukasHirt merged 2 commits into
stable-8.0from
feat/ocisdev-1031-ldap-password-modify
Jul 27, 2026
Merged

LukasHirt merged 2 commits into
stable-8.0from
feat/ocisdev-1031-ldap-password-modify

Conversation

@LukasHirt

Copy link
Copy Markdown

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify and ModifyWithResult with a "not implemented" error, copied over from the existing set of unimplemented ldap.Client methods. This implements both on each client via their existing retry helpers (retry on ConnWithReconnect, do on ConnPool), mirroring the retry-on-network-error behaviour already used by Search/Add/Modify/etc.

This is a prerequisite for unifying oCIS's graph service onto this package's LDAP client: graph's own hand-rolled reconnect implementation fully implements both methods (and actually calls PasswordModify behind GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP), so swapping it onto ConnWithReconnect/ConnPool as-is would silently break that path.

Follow-up to #658 (OCISDEV-1031).

… LDAP clients

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify
and ModifyWithResult with a "not implemented" error, copied over from the
existing set of unimplemented ldap.Client methods. Implement both on each
client via their existing retry helpers (retry on ConnWithReconnect, do on
ConnPool), mirroring the retry-on-network-error behaviour already used by
Search/Add/Modify/etc., so callers relying on the LDAP Password Modify
Extended Operation or on ModifyWithResult work with either client.

Signed-off-by: Lukas Hirt <[email protected]>
@kw-security

kw-security commented Jul 23, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements PasswordModify and ModifyWithResult for the two LDAP client implementations in pkg/utils/ldap (ConnWithReconnect and ConnPool) by wiring them through the existing retry helpers, preventing callers (e.g., graph service) from hitting the previous “not implemented” behavior.

Changes:

  • Add retry-enabled implementations of ModifyWithResult and PasswordModify to ConnWithReconnect.
  • Add pooled implementations of ModifyWithResult and PasswordModify to ConnPool via do.
  • Extend ConnPool tests to cover both methods and add an unreleased changelog entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/utils/ldap/reconnect.go Implements ModifyWithResult/PasswordModify using the existing reconnect retry helper.
pkg/utils/ldap/pool.go Implements ModifyWithResult/PasswordModify using the existing pool do (checkout + retry-on-network-error).
pkg/utils/ldap/pool_test.go Adds forwarding tests for both methods via fakeConn overrides.
changelog/unreleased/enhancement-ldap-pool-password-modify.md Documents the enhancement and links the PR.
Comments suppressed due to low confidence (1)

pkg/utils/ldap/pool_test.go:54

  • fakeConn.ModifyWithResult unconditionally calls modifyWithResultFunc; if fakeConn is created without that override, calling ModifyWithResult will panic. Return a descriptive error when the override is unset to prevent nil-function panics and make test failures clearer.
func (f *fakeConn) ModifyWithResult(req *ldap.ModifyRequest) (*ldap.ModifyResult, error) {
	return f.modifyWithResultFunc(req)
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/utils/ldap/pool_test.go Resolved
@2403905

2403905 commented Jul 23, 2026

Copy link
Copy Markdown

Points worth noting (non-blocking)

  • Retry safety of PasswordModify (minor, pre-existing pattern). On an ErrorNetwork after the server processed the change but before the response arrived, do/retry will transparently
    retry. A password-modify replaying old→new credentials would then fail (old password no longer matches) and surface a confusing error instead of the real success. This is inherent to
    the uniform retry-all-ops design already applied to Modify/Add/ModifyDN, so it's consistent — but PasswordModify is less naturally idempotent than a Modify. Not something to fix in
    this PR; just a known edge worth being aware of when graph switches over.
  • Test coverage gap (minor). Both new tests cover only the happy path. The whole point of these methods is retry-on-network-error, and that branch is not exercised for the new methods
    (e.g., first call returns ldap.NewError(ldap.ErrorNetwork, …), second succeeds; assert one reconnect/re-dial). The pool's generic retry is likely tested elsewhere via Search, so this
    is optional — but a single network-retry test on one of the two new methods would lock in the behavior the changelog advertises.
  • fakeConn nil-func panic (cosmetic). PasswordModify/ModifyWithResult on fakeConn call the func fields unconditionally, so a future test that triggers one without setting the
    corresponding func will panic rather than fail cleanly. Fine for current tests; a guarded fallback would be more robust if this double gets reused.

…dify/ModifyWithResult

Addresses review feedback on #665: fakeConn.PasswordModify/ModifyWithResult
now return an error instead of panicking when their func overrides aren't
set, and the pool's network-error retry path is now exercised for both new
methods (previously only the happy path was tested).

Signed-off-by: Lukas Hirt <[email protected]>
@LukasHirt

Copy link
Copy Markdown
Author

Thanks for the review, replying to each point:

  • Retry safety of PasswordModify: agreed this is real, but it's an existing tradeoff rather than something new — the uniform retry-all-ops behavior was already shipped in feat: [OCISDEV-1031] add opt-in LDAP connection pool #658 for Search/Add/Modify/ModifyDN, and proper retry/backoff design is explicitly deferred to a later story in OCISDEV-1031 ("retry/backoff (Story 2)" is out of scope here). Leaving as-is per your suggestion, but noted for whenever graph switches over onto this client.
  • Test coverage gap: fixed in 9f0a48b — added a network-error-retry test for each of PasswordModify/ModifyWithResult on ConnPool, following the same pattern as TestConnPoolDoRetriesOnceOnNetworkError.
  • fakeConn nil-func panic: fixed in the same commit — both methods now return a descriptive error instead of panicking when their override isn't set.

@LukasHirt

Copy link
Copy Markdown
Author

@2403905 could you please take one more look. THX

@LukasHirt
LukasHirt merged commit 97da4e2 into stable-8.0 Jul 27, 2026
23 of 25 checks passed
@LukasHirt
LukasHirt deleted the feat/ocisdev-1031-ldap-password-modify branch July 27, 2026 08:43
mklos-kw pushed a commit that referenced this pull request Aug 3, 2026
* feat: [OCISDEV-1031] add opt-in LDAP connection pool

Add GetLDAPClientWithPool, a bounded pool of authenticated LDAP
connections, as a drop-in alternative to the existing single, long-lived
reconnecting connection used by the auth/user/group LDAP managers.
Connections are dialed and bound lazily on checkout, unhealthy
connections are discarded and lazily re-dialed rather than eagerly
reconnected, and checkout blocks with a configurable timeout once the
pool is exhausted.

Disabled by default; enable per backend via pool_enabled (plus
pool_size and pool_checkout_timeout) on the LDAP connection config.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address PR review on the LDAP connection pool

Retry once on a network error in ConnPool.do, mirroring
ConnWithReconnect's existing retry behavior: idle pooled connections
aren't health-checked before use, so a connection that went stale
while idle would otherwise fail the caller's first operation instead
of being transparently recovered.

Also: stop leaking the checkout() timer when the semaphore wins the
select, simplify GetLastError to not check out a connection just to
read a value that's meaningless for a pool, and wire a real logger
into GetLDAPClientWithPool so pool dial/checkout debug logging isn't
silently discarded.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address remaining PR review comments on the LDAP pool

Move Config to its own file, document the pool-size/checkout-timeout
defaults, name the dial callback type and document what it does,
require the logger at construction instead of via a mutable setter,
replace the closed-flag mutex with an atomic bool, log Close() errors
on evicted/idle connections, and add GetLDAPClientFromConfig so the
auth/user/group LDAP managers no longer duplicate the pool-vs-reconnect
branch.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] simplify TLS dial and use a weighted semaphore

Collapse the TLS/non-TLS DialURL branch in dialLDAP and
ConnWithReconnect.ldapConnect into a single call:
DialWithTLSConfig(nil) is equivalent to omitting the option, since
crypto/tls treats a nil *tls.Config as the zero configuration.

Replace ConnPool's channel-based semaphore with
golang.org/x/sync/semaphore.Weighted (already a repo dependency),
using context.WithTimeout for the checkout deadline instead of a
manual timer.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] fix unit-tests build on go1.24

wg.Go (sync.WaitGroup.Go) needs go1.25; this branch is rebased onto
stable-8.0, which pins go1.24.0 in go.mod, so CI's unit-tests job
failed to build the test binary. Use wg.Add/Done with a plain
goroutine instead.

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients (#665)

* feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify
and ModifyWithResult with a "not implemented" error, copied over from the
existing set of unimplemented ldap.Client methods. Implement both on each
client via their existing retry helpers (retry on ConnWithReconnect, do on
ConnPool), mirroring the retry-on-network-error behaviour already used by
Search/Add/Modify/etc., so callers relying on the LDAP Password Modify
Extended Operation or on ModifyWithResult work with either client.

Signed-off-by: Lukas Hirt <[email protected]>

* test: guard fakeConn against nil overrides, cover retry on PasswordModify/ModifyWithResult

Addresses review feedback on #665: fakeConn.PasswordModify/ModifyWithResult
now return an error instead of panicking when their func overrides aren't
set, and the pool's network-error retry path is now exercised for both new
methods (previously only the happy path was tested).

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore TLS 1.2 floor for LDAP connections (#672)

tlsConfigFromLDAPConn (shared by GetLDAPClientWithReconnect,
GetLDAPClientWithPool and GetLDAPClientForAuth) built its *tls.Config
without a MinVersion, letting the LDAP client negotiate down to
whatever the Go runtime's default minimum TLS version is. Callers
(oCIS graph service, auth-basic/users/groups managers) previously set
MinVersion: tls.VersionTLS12 themselves before this helper was
introduced in #658. Restore that floor on both the insecure and
CA-cert paths.

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore pinned-CA-only trust for LDAP TLS (#674)

tlsConfigFromLDAPConn's CA-cert branch built its RootCAs pool from
x509.SystemCertPool() plus the configured CA, so configuring a CA
cert also trusted every system-level CA instead of just the pinned
one — a trust-scope widening versus the pre-pool graph service
behavior (x509.NewCertPool()). It also ignored AppendCertsFromPEM's
return value, silently falling back to an unrestricted trust store
on a malformed/empty CA file instead of failing initialization.

Use x509.NewCertPool() and fail when the PEM contains no valid
certificates, matching the behavior callers relied on before this
helper was introduced in #658.

Flagged during review of owncloud/ocis#12660.

Signed-off-by: Lukas Hirt <[email protected]>

docs: point changelog fragments at forward-port PR #679
mklos-kw pushed a commit that referenced this pull request Aug 3, 2026
* feat: [OCISDEV-1031] add opt-in LDAP connection pool

Add GetLDAPClientWithPool, a bounded pool of authenticated LDAP
connections, as a drop-in alternative to the existing single, long-lived
reconnecting connection used by the auth/user/group LDAP managers.
Connections are dialed and bound lazily on checkout, unhealthy
connections are discarded and lazily re-dialed rather than eagerly
reconnected, and checkout blocks with a configurable timeout once the
pool is exhausted.

Disabled by default; enable per backend via pool_enabled (plus
pool_size and pool_checkout_timeout) on the LDAP connection config.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address PR review on the LDAP connection pool

Retry once on a network error in ConnPool.do, mirroring
ConnWithReconnect's existing retry behavior: idle pooled connections
aren't health-checked before use, so a connection that went stale
while idle would otherwise fail the caller's first operation instead
of being transparently recovered.

Also: stop leaking the checkout() timer when the semaphore wins the
select, simplify GetLastError to not check out a connection just to
read a value that's meaningless for a pool, and wire a real logger
into GetLDAPClientWithPool so pool dial/checkout debug logging isn't
silently discarded.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address remaining PR review comments on the LDAP pool

Move Config to its own file, document the pool-size/checkout-timeout
defaults, name the dial callback type and document what it does,
require the logger at construction instead of via a mutable setter,
replace the closed-flag mutex with an atomic bool, log Close() errors
on evicted/idle connections, and add GetLDAPClientFromConfig so the
auth/user/group LDAP managers no longer duplicate the pool-vs-reconnect
branch.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] simplify TLS dial and use a weighted semaphore

Collapse the TLS/non-TLS DialURL branch in dialLDAP and
ConnWithReconnect.ldapConnect into a single call:
DialWithTLSConfig(nil) is equivalent to omitting the option, since
crypto/tls treats a nil *tls.Config as the zero configuration.

Replace ConnPool's channel-based semaphore with
golang.org/x/sync/semaphore.Weighted (already a repo dependency),
using context.WithTimeout for the checkout deadline instead of a
manual timer.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] fix unit-tests build on go1.24

wg.Go (sync.WaitGroup.Go) needs go1.25; this branch is rebased onto
stable-8.0, which pins go1.24.0 in go.mod, so CI's unit-tests job
failed to build the test binary. Use wg.Add/Done with a plain
goroutine instead.

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients (#665)

* feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify
and ModifyWithResult with a "not implemented" error, copied over from the
existing set of unimplemented ldap.Client methods. Implement both on each
client via their existing retry helpers (retry on ConnWithReconnect, do on
ConnPool), mirroring the retry-on-network-error behaviour already used by
Search/Add/Modify/etc., so callers relying on the LDAP Password Modify
Extended Operation or on ModifyWithResult work with either client.

Signed-off-by: Lukas Hirt <[email protected]>

* test: guard fakeConn against nil overrides, cover retry on PasswordModify/ModifyWithResult

Addresses review feedback on #665: fakeConn.PasswordModify/ModifyWithResult
now return an error instead of panicking when their func overrides aren't
set, and the pool's network-error retry path is now exercised for both new
methods (previously only the happy path was tested).

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore TLS 1.2 floor for LDAP connections (#672)

tlsConfigFromLDAPConn (shared by GetLDAPClientWithReconnect,
GetLDAPClientWithPool and GetLDAPClientForAuth) built its *tls.Config
without a MinVersion, letting the LDAP client negotiate down to
whatever the Go runtime's default minimum TLS version is. Callers
(oCIS graph service, auth-basic/users/groups managers) previously set
MinVersion: tls.VersionTLS12 themselves before this helper was
introduced in #658. Restore that floor on both the insecure and
CA-cert paths.

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore pinned-CA-only trust for LDAP TLS (#674)

tlsConfigFromLDAPConn's CA-cert branch built its RootCAs pool from
x509.SystemCertPool() plus the configured CA, so configuring a CA
cert also trusted every system-level CA instead of just the pinned
one — a trust-scope widening versus the pre-pool graph service
behavior (x509.NewCertPool()). It also ignored AppendCertsFromPEM's
return value, silently falling back to an unrestricted trust store
on a malformed/empty CA file instead of failing initialization.

Use x509.NewCertPool() and fail when the PEM contains no valid
certificates, matching the behavior callers relied on before this
helper was introduced in #658.

Flagged during review of owncloud/ocis#12660.

Signed-off-by: Lukas Hirt <[email protected]>

docs: point changelog fragments at forward-port PR #679
mklos-kw pushed a commit that referenced this pull request Aug 4, 2026
* feat: [OCISDEV-1031] add opt-in LDAP connection pool

Add GetLDAPClientWithPool, a bounded pool of authenticated LDAP
connections, as a drop-in alternative to the existing single, long-lived
reconnecting connection used by the auth/user/group LDAP managers.
Connections are dialed and bound lazily on checkout, unhealthy
connections are discarded and lazily re-dialed rather than eagerly
reconnected, and checkout blocks with a configurable timeout once the
pool is exhausted.

Disabled by default; enable per backend via pool_enabled (plus
pool_size and pool_checkout_timeout) on the LDAP connection config.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address PR review on the LDAP connection pool

Retry once on a network error in ConnPool.do, mirroring
ConnWithReconnect's existing retry behavior: idle pooled connections
aren't health-checked before use, so a connection that went stale
while idle would otherwise fail the caller's first operation instead
of being transparently recovered.

Also: stop leaking the checkout() timer when the semaphore wins the
select, simplify GetLastError to not check out a connection just to
read a value that's meaningless for a pool, and wire a real logger
into GetLDAPClientWithPool so pool dial/checkout debug logging isn't
silently discarded.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address remaining PR review comments on the LDAP pool

Move Config to its own file, document the pool-size/checkout-timeout
defaults, name the dial callback type and document what it does,
require the logger at construction instead of via a mutable setter,
replace the closed-flag mutex with an atomic bool, log Close() errors
on evicted/idle connections, and add GetLDAPClientFromConfig so the
auth/user/group LDAP managers no longer duplicate the pool-vs-reconnect
branch.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] simplify TLS dial and use a weighted semaphore

Collapse the TLS/non-TLS DialURL branch in dialLDAP and
ConnWithReconnect.ldapConnect into a single call:
DialWithTLSConfig(nil) is equivalent to omitting the option, since
crypto/tls treats a nil *tls.Config as the zero configuration.

Replace ConnPool's channel-based semaphore with
golang.org/x/sync/semaphore.Weighted (already a repo dependency),
using context.WithTimeout for the checkout deadline instead of a
manual timer.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] fix unit-tests build on go1.24

wg.Go (sync.WaitGroup.Go) needs go1.25; this branch is rebased onto
stable-8.0, which pins go1.24.0 in go.mod, so CI's unit-tests job
failed to build the test binary. Use wg.Add/Done with a plain
goroutine instead.

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients (#665)

* feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify
and ModifyWithResult with a "not implemented" error, copied over from the
existing set of unimplemented ldap.Client methods. Implement both on each
client via their existing retry helpers (retry on ConnWithReconnect, do on
ConnPool), mirroring the retry-on-network-error behaviour already used by
Search/Add/Modify/etc., so callers relying on the LDAP Password Modify
Extended Operation or on ModifyWithResult work with either client.

Signed-off-by: Lukas Hirt <[email protected]>

* test: guard fakeConn against nil overrides, cover retry on PasswordModify/ModifyWithResult

Addresses review feedback on #665: fakeConn.PasswordModify/ModifyWithResult
now return an error instead of panicking when their func overrides aren't
set, and the pool's network-error retry path is now exercised for both new
methods (previously only the happy path was tested).

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore TLS 1.2 floor for LDAP connections (#672)

tlsConfigFromLDAPConn (shared by GetLDAPClientWithReconnect,
GetLDAPClientWithPool and GetLDAPClientForAuth) built its *tls.Config
without a MinVersion, letting the LDAP client negotiate down to
whatever the Go runtime's default minimum TLS version is. Callers
(oCIS graph service, auth-basic/users/groups managers) previously set
MinVersion: tls.VersionTLS12 themselves before this helper was
introduced in #658. Restore that floor on both the insecure and
CA-cert paths.

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore pinned-CA-only trust for LDAP TLS (#674)

tlsConfigFromLDAPConn's CA-cert branch built its RootCAs pool from
x509.SystemCertPool() plus the configured CA, so configuring a CA
cert also trusted every system-level CA instead of just the pinned
one — a trust-scope widening versus the pre-pool graph service
behavior (x509.NewCertPool()). It also ignored AppendCertsFromPEM's
return value, silently falling back to an unrestricted trust store
on a malformed/empty CA file instead of failing initialization.

Use x509.NewCertPool() and fail when the PEM contains no valid
certificates, matching the behavior callers relied on before this
helper was introduced in #658.

Flagged during review of owncloud/ocis#12660.

Signed-off-by: Lukas Hirt <[email protected]>

docs: point changelog fragments at forward-port PR #680
mklos-kw pushed a commit that referenced this pull request Aug 4, 2026
* feat: [OCISDEV-1031] add opt-in LDAP connection pool

Add GetLDAPClientWithPool, a bounded pool of authenticated LDAP
connections, as a drop-in alternative to the existing single, long-lived
reconnecting connection used by the auth/user/group LDAP managers.
Connections are dialed and bound lazily on checkout, unhealthy
connections are discarded and lazily re-dialed rather than eagerly
reconnected, and checkout blocks with a configurable timeout once the
pool is exhausted.

Disabled by default; enable per backend via pool_enabled (plus
pool_size and pool_checkout_timeout) on the LDAP connection config.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address PR review on the LDAP connection pool

Retry once on a network error in ConnPool.do, mirroring
ConnWithReconnect's existing retry behavior: idle pooled connections
aren't health-checked before use, so a connection that went stale
while idle would otherwise fail the caller's first operation instead
of being transparently recovered.

Also: stop leaking the checkout() timer when the semaphore wins the
select, simplify GetLastError to not check out a connection just to
read a value that's meaningless for a pool, and wire a real logger
into GetLDAPClientWithPool so pool dial/checkout debug logging isn't
silently discarded.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] address remaining PR review comments on the LDAP pool

Move Config to its own file, document the pool-size/checkout-timeout
defaults, name the dial callback type and document what it does,
require the logger at construction instead of via a mutable setter,
replace the closed-flag mutex with an atomic bool, log Close() errors
on evicted/idle connections, and add GetLDAPClientFromConfig so the
auth/user/group LDAP managers no longer duplicate the pool-vs-reconnect
branch.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] simplify TLS dial and use a weighted semaphore

Collapse the TLS/non-TLS DialURL branch in dialLDAP and
ConnWithReconnect.ldapConnect into a single call:
DialWithTLSConfig(nil) is equivalent to omitting the option, since
crypto/tls treats a nil *tls.Config as the zero configuration.

Replace ConnPool's channel-based semaphore with
golang.org/x/sync/semaphore.Weighted (already a repo dependency),
using context.WithTimeout for the checkout deadline instead of a
manual timer.

Signed-off-by: Lukas Hirt <[email protected]>

* fix: [OCISDEV-1031] fix unit-tests build on go1.24

wg.Go (sync.WaitGroup.Go) needs go1.25; this branch is rebased onto
stable-8.0, which pins go1.24.0 in go.mod, so CI's unit-tests job
failed to build the test binary. Use wg.Add/Done with a plain
goroutine instead.

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients (#665)

* feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients

ConnWithReconnect and ConnPool (pkg/utils/ldap) stubbed out PasswordModify
and ModifyWithResult with a "not implemented" error, copied over from the
existing set of unimplemented ldap.Client methods. Implement both on each
client via their existing retry helpers (retry on ConnWithReconnect, do on
ConnPool), mirroring the retry-on-network-error behaviour already used by
Search/Add/Modify/etc., so callers relying on the LDAP Password Modify
Extended Operation or on ModifyWithResult work with either client.

Signed-off-by: Lukas Hirt <[email protected]>

* test: guard fakeConn against nil overrides, cover retry on PasswordModify/ModifyWithResult

Addresses review feedback on #665: fakeConn.PasswordModify/ModifyWithResult
now return an error instead of panicking when their func overrides aren't
set, and the pool's network-error retry path is now exercised for both new
methods (previously only the happy path was tested).

Signed-off-by: Lukas Hirt <[email protected]>

---------

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore TLS 1.2 floor for LDAP connections (#672)

tlsConfigFromLDAPConn (shared by GetLDAPClientWithReconnect,
GetLDAPClientWithPool and GetLDAPClientForAuth) built its *tls.Config
without a MinVersion, letting the LDAP client negotiate down to
whatever the Go runtime's default minimum TLS version is. Callers
(oCIS graph service, auth-basic/users/groups managers) previously set
MinVersion: tls.VersionTLS12 themselves before this helper was
introduced in #658. Restore that floor on both the insecure and
CA-cert paths.

Signed-off-by: Lukas Hirt <[email protected]>

fix(ldap): [OCISDEV-1031] restore pinned-CA-only trust for LDAP TLS (#674)

tlsConfigFromLDAPConn's CA-cert branch built its RootCAs pool from
x509.SystemCertPool() plus the configured CA, so configuring a CA
cert also trusted every system-level CA instead of just the pinned
one — a trust-scope widening versus the pre-pool graph service
behavior (x509.NewCertPool()). It also ignored AppendCertsFromPEM's
return value, silently falling back to an unrestricted trust store
on a malformed/empty CA file instead of failing initialization.

Use x509.NewCertPool() and fail when the PEM contains no valid
certificates, matching the behavior callers relied on before this
helper was introduced in #658.

Flagged during review of owncloud/ocis#12660.

Signed-off-by: Lukas Hirt <[email protected]>

docs: point changelog fragments at forward-port PR #680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants