Skip to content

feat(ldap): [OCISDEV-1031] add opt-in LDAP connection pool - #12660

Merged
LukasHirt merged 4 commits into
stable-8.0from
feat/ocisdev-1031-ldap-pool
Jul 30, 2026
Merged

LukasHirt merged 4 commits into
stable-8.0from
feat/ocisdev-1031-ldap-pool

Conversation

@LukasHirt

@LukasHirt LukasHirt commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Bumps the vendored reva dependency to pick up the opt-in bounded LDAP connection pool (owncloud/reva#658, owncloud/reva#665), and wires it into oCIS:

  • Adds pool_enabled/pool_size/pool_checkout_timeout config to auth-basic, users, groups and graph.
  • Forwards the new config into the reva config map for auth-basic, users and groups.
  • Unifies the graph service's identity backend onto reva's LDAP client (utils.GetLDAPClientFromConfig) instead of its own hand-rolled reconnecting client, now that reva implements PasswordModify and ModifyWithResult on both LDAP clients (feat: [OCISDEV-1031] implement PasswordModify and ModifyWithResult on LDAP clients reva#665) — removing the second, now-redundant implementation.
  • Adds a dedicated ldap-pool-tests CI job that reruns the apiGraphUser/apiGraph/apiGraphGroup acceptance suites with OCIS_LDAP_POOL_ENABLED=true, in addition to their existing pooling-disabled runs.
  • Bumps github.com/go-chi/chi/v5 and go.opentelemetry.io/otel to fix newly-disclosed, unrelated govulncheck findings on stable-8.0's baseline that were blocking CI on this PR.

Pooling is off by default and fully backwards compatible: with it disabled, behavior is unchanged from the existing single-connection ConnWithReconnect path.

Related Issue

Motivation and Context

OCISDEV-1031 is Story 1 of the OCISDEV-1030 epic (LDAP client hardening for the consolidated central-idm architecture, ~600 connections across 200 clusters). The goal is to replace the single long-lived LDAP connection per backend with a bounded pool, so concurrent requests no longer serialize on one socket.

How Has This Been Tested?

  • test environment: local oCIS build (stable-8.0) against the embedded LDAP idm, with OCIS_LDAP_POOL_ENABLED=true and GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP=true set; plus CI's new ldap-pool-tests job (apiGraphUser, apiGraph, apiGraphGroup with OCIS_LDAP_POOL_ENABLED=true).
  • test case 1: basic auth login and /graph/v1.0/me — succeeds with pooling enabled.
  • test case 2: list users and list groups via the graph API — succeed with pooling enabled.
  • test case 3: password change via PATCH /graph/v1.0/users/{id} with passwordProfile (exercises PasswordModify through reva's client) — old password rejected afterwards, new password authenticates successfully.
  • test case 4: 20 concurrent authenticated requests against the pool — all succeed, no errors logged.
  • test case 5: go build ./..., go vet ./..., and existing unit tests for auth-basic/users/groups/graph all pass unmodified (pooling disabled, default behavior confirmed unchanged).
  • test case 6: acceptance suites apiGraphUser, apiGraph, apiGraphGroup re-run with OCIS_LDAP_POOL_ENABLED=true in CI (ldap-pool-tests job), covering login, user/group CRUD and password modify against the pooled LDAP client end-to-end.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@kw-security

kw-security commented Jul 27, 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.

@LukasHirt LukasHirt self-assigned this Jul 27, 2026
@2403905

2403905 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Let's separate the dependency bump and pull request.

@2403905

2403905 commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Suggestions

1. Graph service loses the explicit TLS MinVersion: tls.VersionTLS12 floor (minor security regression). The old graph code built its tls.Config with MinVersion: tls.VersionTLS12 for both the insecure and CA paths. The new path delegates to reva's tlsConfigFromLDAPConn, which sets no MinVersion — the insecure branch sets only InsecureSkipVerify: true, and the CA branch sets only RootCAs. So with pooling either on or off, the graph LDAP client now negotiates down to whatever Go's default minimum is. This is a behavior change introduced by this PR for the graph service specifically. Worth confirming it's acceptable (auth-basic/users/groups already used reva's helper, so they're unchanged — only graph regresses here).

2. pool_size / pool_checkout_timeout have no defaults in oCIS DefaultConfig(). Only PoolEnabled: false is set in the four defaultconfig.go files. PoolSize/PoolCheckoutTimeout are left as Go zero values (0 / 0s), relying on reva's NewLDAPPool to substitute 5 / 30s when <= 0. That works, but it means ocis init / the generated yaml will show pool_size: 0, which reads as "zero connections" to an operator rather than "default 5". Consider setting the real defaults (5, 30s) in DefaultConfig() so the documented defaults match what's emitted, matching the pattern used for other tunables.

3. CA-cert error path in graph is now unreachable dead code. In the refactored setIdentityBackends, the if options.Config.Identity.LDAP.CACert != "" block now only calls WaitForCA — the actual cert reading/parsing moved into reva's helper. That's fine, but note WaitForCA returns nil even when the cert never appears (it only warns), so a genuinely missing CA now surfaces later as a dial error from the first checkout rather than at startup. Behavior is arguably acceptable but slightly less eager than before. No action required; just flagging.

@LukasHirt

Copy link
Copy Markdown
Contributor Author

Split the dependency bump into its own PR as requested: #12662 (cc @2403905). Rebased this branch to drop that commit.

@LukasHirt

Copy link
Copy Markdown
Contributor Author

Addressed:

  1. TLS MinVersion regression — this lives in vendored reva's tlsConfigFromLDAPConn (shared by all three GetLDAPClient* constructors), not in oCIS code, so it affects auth-basic/users/groups too, not just graph, once fixed. Opened fix(ldap): restore TLS 1.2 floor for LDAP connections reva#672 to restore MinVersion: tls.VersionTLS12 on both the insecure and CA-cert paths upstream (cc @2403905 for review there). Will bump the vendored reva dep here once that merges.
  2. pool_size/pool_checkout_timeout defaults — fixed in 7c5773b: set the real defaults (5, 30s) in all four DefaultConfig() functions so the generated yaml no longer shows pool_size: 0.
  3. CA-cert error path — agreed no action needed, per your own note.

@2403905 2403905 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please first amend the reva in accordance with the objections.

LukasHirt added a commit to owncloud/reva that referenced this pull request Jul 29, 2026
…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]>
@LukasHirt

Copy link
Copy Markdown
Contributor Author

Reva amended in accordance with both sets of objections:

Both merged into reva stable-8.0; bumped the vendored dependency here in b79f74b to pick them up. go build ./... and the affected services' unit tests (graph, auth-basic, users, groups) pass.

Bump the vendored reva dependency to pick up the opt-in bounded LDAP
connection pool (owncloud/reva#658, #665), and wire it into oCIS: add
pool_enabled/pool_size/pool_checkout_timeout config to auth-basic,
users, groups and graph, forward it into the reva config map for the
first three, and unify graph's identity backend onto reva's LDAP
client (utils.GetLDAPClientFromConfig) instead of its own hand-rolled
reconnecting client, now that reva implements PasswordModify and
ModifyWithResult on both LDAP clients. Pooling is off by default and
fully backwards compatible.

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

Add a dedicated ldap-pool-tests job to acceptance-tests.yml that reruns
apiGraphUser/apiGraph/apiGraphGroup with OCIS_LDAP_POOL_ENABLED=true, so
concurrent behat requests exercise checkout/release, eviction and the
pooled PasswordModify/ModifyWithResult path end-to-end, in addition to
the existing pooling-disabled runs of the same suites.

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

Only PoolEnabled: false was set in the four defaultconfig.go files;
PoolSize/PoolCheckoutTimeout were left as Go zero values (0/0s),
relying on reva's NewLDAPPool substituting 5/30s when <= 0. That
reads as "zero connections" to an operator in the generated yaml
config rather than "default 5". Set the real defaults (5, 30s)
so documented defaults match what's emitted.

Signed-off-by: Lukas Hirt <[email protected]>
Bumps the vendored reva dependency to owncloud/reva@8ee2020, picking
up owncloud/reva#672 (restore MinVersion: tls.VersionTLS12 on LDAP
TLS connections) and owncloud/reva#674 (restore pinned-CA-only trust
and PEM validation for the CA-cert path), both flagged during review
of this PR.

Signed-off-by: Lukas Hirt <[email protected]>
@LukasHirt
LukasHirt force-pushed the feat/ocisdev-1031-ldap-pool branch from b79f74b to 7ee1c2b Compare July 29, 2026 08:27
@mzner
mzner self-requested a review July 30, 2026 07:34
@LukasHirt
LukasHirt merged commit 9d9a037 into stable-8.0 Jul 30, 2026
59 checks passed
@LukasHirt
LukasHirt deleted the feat/ocisdev-1031-ldap-pool branch July 30, 2026 07:34
mklos-kw pushed a commit to owncloud/reva 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 to owncloud/reva 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 to owncloud/reva 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 to owncloud/reva 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.

4 participants