In cached bind mode the refresh rebuilt the provider instance but kept
the previous session binder's direct binder, and that binder reads the
bind flow, the unbind flow, MFA support and the base DN from the
instance it was built with. A change to any of them on the provider
never reached a running outpost: it carried on executing the old bind
flow until the process was restarted, while the refresh log said the
new flow had been loaded. The cached results survived the refresh too,
so a bind refused under the old settings stayed refused, and one
accepted stayed accepted, for the life of its entry.
The direct binder is now always built from the new instance. The
session cache is carried over only when the settings that decide a
bind's outcome are unchanged; when one of them changes, the old cache
is stopped and a fresh one started, so every pair of credentials runs
the new flow once more and is cached again under it. The five-minute
refresh keeps the cache in the ordinary case; the cost lands only when
an administrator changed something, which is what the change was for.
Also fixes the comment on the caching line, which said the opposite of
what the code does: a result is cached whenever the bind itself
completed, refusals included; only a transport error is left uncached.
Tests: a refresh with unchanged settings keeps the cached sessions; a
changed bind flow, unbind flow, MFA setting or base DN discards them,
refusals included; and the direct binder answers for the new instance's
base DN after a refresh. The last two fail on the previous code.
Co-authored-by: Jens L. <[email protected]>
With authentik under AUTHENTIK_WEB__PATH, outposts could not reach it:
- The RAC outpost built its session websocket URL from the API client's
scheme and host only, so it dialed /ws/outpost_rac/... and got a 404,
while the control websocket already kept the path. Both now go
through one dialer, which also gives the session websocket the unix
socket support and query parameters of the control websocket.
- The API base was the path of AUTHENTIK_HOST with "api/v3" appended, so
a path without a trailing slash, such as /authentik, became
/authentikapi/v3. The websockets already joined the path correctly.
- The default outpost config, which the admin interface pre-fills for
new outposts, set authentik_host to the server root.
Closes: #26803
The memory searcher discarded the errors from the users and groups
paginators and always replaced its snapshot with the result. When the
core API fails during a provider refresh, the paginator returns an
empty list, so one transient error replaced a known-good directory
with an empty one. Every search then returned no entries or was
denied until a later refresh succeeded or the outpost restarted.
fetch() now checks both errors. If either fetch failed and a previous
snapshot exists, it logs the error and keeps the previous snapshot.
Users and groups are kept together, so a snapshot never mixes data
from two fetches. On the first fetch there is no previous snapshot,
so the searcher stores what it got, as before, and the next
successful refresh replaces it.
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Jens L. <[email protected]>
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]>
* core, internal, packages: fix British spellings flagged by cspell
Apply American spellings in Python docstrings/comments, Go log messages, a Rust doc comment, and a template comment (behaviour->behavior, initialise->initialize, finalise->finalize, etc.). Part of enabling cspell's British-spelling rule; the rule itself lands in a separate PR once all areas are clean.
Co-Authored-By: Playpen Agent <[email protected]>
* gen
Signed-off-by: Jens Langhammer <[email protected]>
---------
Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Playpen Agent <[email protected]>
Co-authored-by: Jens Langhammer <[email protected]>
The outpost API controller shares a single *websocket.Conn across
multiple goroutines: the event-handler loop, the 10s health ticker
(SendEventHello), the shutdown path (WriteMessage close), initEvent
writing the hello frame on (re)connect, and RAC session handlers that
also invoke SendEventHello. gorilla/websocket explicitly documents that
concurrent WriteMessage/WriteJSON calls are unsafe and will panic with
"concurrent write to websocket connection", which takes the outpost
(and embedded-outpost authentik-server) pod down.
Fix by adding a sync.Mutex on APIController guarding every write path
on eventConn (initEvent hello, Shutdown close message, SendEventHello).
Reads (ReadJSON in startEventHandler) are left unsynchronized as
gorilla permits a single concurrent reader alongside a writer.
Minimal, localized change: no API changes, no behavior changes, writes
are already infrequent so lock contention is negligible.
Refs #11090
Co-authored-by: curiosity <[email protected]>
* re-instate previously flaky test
Signed-off-by: Jens Langhammer <[email protected]>
* break up big file
Signed-off-by: Jens Langhammer <[email protected]>
* move geoip data to subdir
Signed-off-by: Jens Langhammer <[email protected]>
* i am but a weak man
Signed-off-by: Jens Langhammer <[email protected]>
* fix ldap disconnect in testing
Signed-off-by: Jens Langhammer <[email protected]>
* account for mismatched uid due to test server process
Signed-off-by: Jens Langhammer <[email protected]>
---------
Signed-off-by: Jens Langhammer <[email protected]>
* internal: make http timeouts configurable
Signed-off-by: Jens Langhammer <[email protected]>
* Changed formatting to match the rest of the doc
---------
Signed-off-by: Jens Langhammer <[email protected]>
Co-authored-by: Dewi Roberts <[email protected]>
Use r.URL.EscapedPath() instead of r.URL.Path when building the
redirect URL in redirectToStart(). The decoded Path field converts
%2F to /, which url.JoinPath then collapses via path.Clean, stripping
encoded slashes from the URL. EscapedPath() preserves the original
encoding, fixing 301 redirects that break apps like RabbitMQ which
use %2F in their API paths.
* Revert "admin/files: support %(theme)s variable in media file paths (#19108)"
This reverts commit 1a963d27c8.
* admin/files: add centralized theme variable support for file URLs
Overview:
Adds support for `%(theme)s` placeholder in file paths, which allows theme-specific assets (like logos, backgrounds, icons) to be served based on the user's current theme (light/dark).
This replaces the previous implementation (reverted in this PR) which only handled theme substitution in the Go file backend and instead uses the new approach which centralizes theme logic and works across both backends.
Testing:
Try out the following for the file and s3 backend:
* Ensure themed images load
* Ensure non-themed images load
Motivation:
Internal
* brands: fix tests
* admin/files: s3 backend: fix tests
.xyz is a known MIME type for chemical/molecular structure files
* admin/files: api: fix tests
* core: fix tests
* admin/files: manager: fix tests
* admin/files: Support themed urls for passthrough backend
* admin/files: Create and use ThemedUrlsSerializer
* root: Regenerate
* core: Add read_only=True since it's a computed field from the model
* root: Regenerate
* web: Use the ThemedUrlsSerializer
* web, core: Fix frontend build
* core: Lint
* admin/files: Fix tests following CodeQL
* flows, providers: fix tests
* Fix incorect comparison of redirect URL and CookieDomain. Fixes#15685
According to docs, URL.Host contains the host and port, while Hostname
returns only the host without the port. CookieDomain obviously does not
contain the port. string.HasSuffix function is used, so if a port is set
in the redirect URL, this check always fails.
* Fixed missing parentheses
---------
Co-authored-by: Dewi Roberts <[email protected]>