fix: forward field selector to sessions backend#590
Merged
zachsmith1 merged 1 commit intomainfrom Apr 30, 2026
Merged
Conversation
milo's local Sessions REST handler was building a fresh empty ListOptions and discarding the caller's FieldSelector before delegating to the DynamicProvider backend that proxies to auth-provider-zitadel. The "ignore selectors; self-scoped list delegated to provider" comment was written before the cross-user lookup pattern landed in #588. This is the missing piece for status.userUID=<uid> lookups: the field selector now reaches auth-provider-zitadel, where the REST handler runs its own SAR check against milo using the caller identity (preserved via X-Remote-* headers in DynamicProvider.dynForUser). Without this, the handler always saw an empty selector, fell back to the caller's UID (empty for service accounts), and returned 0 sessions. Also forwards LabelSelector for completeness. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
scotwells
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
milo's local Sessions REST handler at
internal/apiserver/identity/sessions/rest.go:43was building a fresh emptyListOptions{}and discarding the caller'sFieldSelectorbefore delegating to theDynamicProviderbackend that proxies to auth-provider-zitadel. The comment said "ignore selectors; self-scoped list delegated to provider" — written before the cross-user lookup pattern landed (#588 / datum-cloud/auth-provider-zitadel#69).Symptom (observed live in staging)
After #588 merged, the field-selector validation 400 went away — but the request still returned no sessions for the targeted user. Tracing showed:
LIST sessions?fieldSelector=status.userUID=<uid>✓ListOptions{}(selector dropped)LIST sessions?timeout=3s(no selector)opts.FieldSelector == nil→ falls back tou.GetUID()→ caller issystem:control@fraud.miloapis.com(service account, no UID) →uid=""→ 0 sessionsapiserver logs confirmed the empty UID:
Fix
Forward
opts.FieldSelector(andopts.LabelSelectorfor completeness) into themetav1.ListOptionspassed toBackend.ListSessions. TheDynamicProviderbackend already preserves the caller identity via X-Remote-* headers (internal/apiserver/identity/sessions/dynamic.go:108-119), so auth-provider-zitadel's REST handler still runs its own SAR check against milo and rejects unauthorized cross-user reads.Test plan
go build ./...cleango test ./internal/apiserver/identity/sessions/...clean0 session(s) for userID="". Verify viakubectl -n datum-iam-system logs deploy/auth-provider-zitadel-apiserver | grep "Listing sessions"showinguid=<actual-target-uid>.Related
status.userUIDselector consumer + SAR enforcement🤖 Generated with Claude Code