Skip to content

feat(identity): Forward the status.active selector on sessions - #1071

Merged
yahyafakhroji merged 1 commit into
mainfrom
feat/session-active-selector
Dec 1, 2026
Merged

yahyafakhroji merged 1 commit into
mainfrom
feat/session-active-selector

Conversation

@yahyafakhroji

Copy link
Copy Markdown
Contributor

Problem
Milo dropped the status.active=true field selector on sessions.identity.miloapis.com list requests. The Session field label conversion accepted only status.userUID, metadata.name and metadata.namespace, and mapped every other label to an empty term, which apimachinery treats as match-everything. The zitadel provider never saw the selector, so cloud-portal's Active Sessions page got the full list.

Solution
Session now has its own conversion func that also accepts status.active. UserIdentity and Passkey keep the shared func and still drop the label. Other labels behave as before, including the silent drop of unknown ones. New tests check the conversion per kind and that the sessions REST List forwards status.active=true to the backend, alone and with status.userUID.

Refs milo-os/zitadel-provider#231
Refs milo-os/zitadel-provider#233

The milo aggregator dropped status.active from session list requests,
so the sessions provider never saw the selector and returned every
session. Session now has its own field label conversion that accepts
status.active. UserIdentity and Passkey keep the shared conversion and
still drop it.

@scotwells scotwells 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.

The change forwards the active filter only for Sessions. The forwarding tests cover it both alone and with the user filter; Passkey and UserIdentity behavior stays unchanged.

@ecv ecv 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.

Approve.

The change only adds status.active as an accepted Session field-label, so the apiserver forwards it instead of silently dropping it; it widens no scope.

  • sessions/rest.go List forwards opts.FieldSelector.String() verbatim to the backend, and the identity-aware filtering and SAR check run there (auth-provider-zitadel), unchanged. A selector term can only narrow results; status.userUID cross-user lookups already existed and keep the same backend gate.
  • status.active is accepted for Session only. TestInstall_StatusActiveIsSessionOnly confirms UserIdentity and Passkey still drop it, and status.provider still drops.
  • Tests: go test ./pkg/apis/identity/ ./internal/apiserver/identity/sessions/ pass. With the status.active branch disabled, TestInstall_SessionFieldSelectors and TestList_ForwardsStatusActiveSelector both fail, so the guard is covered.
  • Follow-ups: the backend's handling of status.active lives in another repo and is untested here; add a cross-repo contract test. Unknown selector terms are still silently dropped to "everything", which is how this bug hid; consider rejecting them.

@yahyafakhroji

Copy link
Copy Markdown
Contributor Author

Thanks @ecv and @scotwells for the reviews! I filed both follow-ups ecv raised: #1072 for rejecting unknown selector labels, and milo-os/zitadel-provider#234 for a contract test through Milo into the provider.

@yahyafakhroji
yahyafakhroji merged commit f429c12 into main Dec 1, 2026
9 checks passed
@yahyafakhroji
yahyafakhroji deleted the feat/session-active-selector branch December 1, 2026 02:58
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.

3 participants