Skip to content

chore: add field selector support for staff user queries#69

Open
OscarLlamas6 wants to merge 6 commits intomainfrom
feat/field-selector-support-for-staff-users
Open

chore: add field selector support for staff user queries#69
OscarLlamas6 wants to merge 6 commits intomainfrom
feat/field-selector-support-for-staff-users

Conversation

@OscarLlamas6
Copy link
Copy Markdown
Contributor

Enable staff users to query other users' identities and sessions by adding field selector support to the REST storage implementations.

Changes:

  • Add field selector parsing in useridentities List() method
  • Add field selector parsing in sessions List() method
  • Support both "status.userUID=" and "userUID=" syntax
  • Maintain backward compatibility: users without field selector see only their own resources (existing behavior)
  • Add extractUserUIDFromFieldSelector() helper function

This allows staff users to retrieve identity provider links and sessions for any user by specifying the target userUID in the field selector, while regular users continue to see only their own data.

Authorization is delegated to Milo (AlwaysAllowAuthorizer), so RBAC policies in Milo control who can use field selectors.

Related: datum-cloud/staff-portal#284

Enable staff users to query other users' identities and sessions by
adding field selector support to the REST storage implementations.

Changes:
- Add field selector parsing in useridentities List() method
- Add field selector parsing in sessions List() method
- Support both "status.userUID=<uid>" and "userUID=<uid>" syntax
- Maintain backward compatibility: users without field selector see
  only their own resources (existing behavior)
- Add extractUserUIDFromFieldSelector() helper function

This allows staff users to retrieve identity provider links and
sessions for any user by specifying the target userUID in the field
selector, while regular users continue to see only their own data.

Authorization is delegated to Milo (AlwaysAllowAuthorizer), so RBAC
policies in Milo control who can use field selectors.

Related: datum-cloud/staff-portal#[issue-number]
Oscar Llamas and others added 5 commits February 5, 2026 12:09
Change restart policy from 'always' to 'on-failure:3' to prevent
infinite restart loops when Zitadel migrations fail during E2E tests.
This allows the test to fail fast and show meaningful error logs
instead of timing out after 600 seconds.
Implement authorization checks to restrict field selector usage to
staff users only. Regular users can only view their own identities
and sessions, while staff users (identified by group membership) can
query other users' data using field selectors.

Changes:
- Add isStaffUser() helper to check for privileged group membership
- Verify authorization before allowing cross-user queries in List()
- Support staff groups: system:masters, staff, admin, datum:staff
- Return Forbidden error for unauthorized field selector attempts
- Add detailed logging for authorization decisions

Authorization flow:
1. Extract target userUID from field selector if present
2. If target differs from authenticated user, check group membership
3. Allow if user belongs to staff/admin group, deny otherwise
4. Regular users without field selector see only their own data

This enables staff portal to view user identities and sessions for
support purposes while maintaining security for regular users.

Related: datum-cloud/staff-portal (staff user authorization)
Implement authorization checks to restrict field selector usage to
staff users only. Regular users can only view their own identities
and sessions, while staff users (identified by Zitadel group membership)
can query other users' data using field selectors.

Changes:
- Add isStaffUser() helper to check for privileged group membership
- Verify authorization before allowing cross-user queries in List()
- Support Zitadel groups: staff-users, fraud-manager, system:masters
- Return Forbidden error for unauthorized field selector attempts
- Add detailed logging for authorization decisions

Authorization flow:
1. Extract target userUID from field selector if present
2. If target differs from authenticated user, check group membership
3. Allow if user belongs to staff/fraud-manager group, deny otherwise
4. Regular users without field selector see only their own data

This enables staff portal to view user identities and sessions for
support purposes while maintaining security for regular users.

Zitadel groups are passed via JWT claims and verified at the API
server level before delegating to the backend provider.
Update milo to v0.19.1-0.20260226053921-0d9c1d378aab from feat/identity-field-selector-support branch.
This brings in field label conversion functions for status.userUID field selector support.
Update milo to ca31333 which includes field selector support
with debug logging removed.
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.

1 participant