Repository navigation
providers/ldap: fix memory leak in the cached searcher (cherry-pick #26028 to version-2026.8) - #26050
Conversation
internal/outpost/ldap: stop retaining pointers into the cached user slice The memory searcher stored `&ms.users[i]` on a non-searching bind DN's flags the first time that user searched, and never cleared it. Every refresh replaces `ms.users`, so each stored pointer kept an entire superseded copy of the directory alive for the life of the process. On a directory of ~6k users with ~70k memberships, each distinct password login after a restart pinned ~100-160 MB until the outpost was killed for memory. The same pointer also froze the user's own entry (memberOf) at its first-search state. Replace the two bare slices with an immutable snapshot (users, groups and a pk index) behind an atomic pointer. fetch() builds a new snapshot and swaps it; Search() loads the snapshot once per request, resolves the bound user by pk against the current one and copies the value for the duration of the request. Nothing is written to the per-DN flags. This also removes the unsynchronised slice replacement during a refresh and the per-request linear scan over all users. The regression test drives the searcher against a fake core: a non-searching user's self-read must reflect a group change after the searcher is re-initialised the way Refresh() does, and the DN's flags must not carry a user pointer afterwards. It fails on the previous code on both counts. Co-authored-by: Dewi Roberts <[email protected]>
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## version-2026.8 #26050 +/- ##
==================================================
+ Coverage 91.77% 91.81% +0.04%
==================================================
Files 1160 1160
Lines 74621 74621
Branches 4054 4054
==================================================
+ Hits 68482 68514 +32
+ Misses 6097 6065 -32
Partials 42 42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Signed-off-by: Jens Langhammer <[email protected]>
|
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-c7baa00cbc4cdd4f57c595ad7467515f7edc0215
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-c7baa00cbc4cdd4f57c595ad7467515f7edc0215Afterwards, run the upgrade commands from the latest release notes. |
Cherry-pick of #26028 to
version-2026.8branch.Original PR: #26028
Original Author: @cheesegrits
Cherry-picked commit: def9ac7