feat(identity): enable field selector support for staff users#504
Open
OscarLlamas6 wants to merge 11 commits intomainfrom
Open
feat(identity): enable field selector support for staff users#504OscarLlamas6 wants to merge 11 commits intomainfrom
OscarLlamas6 wants to merge 11 commits intomainfrom
Conversation
Pass field selectors from REST layer to backend provider to enable staff users to query other users' identities and sessions. This is required for the staff portal to view user identity provider links and active sessions for support purposes. Changes: - Pass field selector from ListOptions to backend in useridentities - Pass field selector from ListOptions to backend in sessions - Update README documentation with field selector usage and security model - Add test documentation for field selector authorization scenarios Authorization model: 1. Milo RBAC: PolicyBinding grants access to identity resources 2. Backend authorization: Provider validates group membership - Regular users: Can only see their own data (no field selector) - Staff users: Can use field selectors to query other users - Groups: staff-users, fraud-manager (configured in Zitadel) Security: - Backward compatible: Regular users unaffected - Defense in depth: Two layers of authorization - Audit logging: All requests logged with user context - Explicit deny: Non-staff users cannot use field selectors This changes the previous 'self-scoped' design where field selectors were intentionally ignored. The new behavior maintains self-scoped access for regular users while enabling cross-user queries for staff. Related: datum-cloud/staff-portal (staff user authorization) Related: datum-cloud/auth-provider-zitadel (backend authorization)
Contributor
Contributor
Author
|
Needed for datum-cloud/staff-portal#284 |
Contributor
|
@OscarLlamas6 based on this error message you also need to register
Looks like you do this by registering the supported fields with the AddFieldLabelConversionFunc, see the activity service for an example. |
Add field label conversion functions for UserIdentity and Session resources to enable status.userUID as a supported field selector. This allows the API server to validate field selector queries before passing them to the backend provider. Changes: - Add UserIdentityFieldLabelConversionFunc for UserIdentity resources - Add SessionFieldLabelConversionFunc for Session resources - Register both conversion functions in addKnownTypes - Support field selectors: metadata.name, metadata.namespace, status.userUID This fixes the error: "status.userUID" is not a known field selector: only "metadata.name", "metadata.namespace" Now staff users can successfully query: kubectl get useridentities --field-selector=status.userUID=<user-id> Related: PR feedback on field selector validation
766dcb1 to
a8be41d
Compare
Use runtime.NewParameterCodec(legacyscheme.Scheme) instead of metav1.ParameterCodec. The legacyscheme already has identity scheme installed with field label conversions. Add unit tests for field selector validation.
Create dedicated Identity Scheme following Activity API pattern. This ensures field label conversion functions are properly registered and used by the API server for field selector validation. - Add pkg/apis/identity/install package - Create dedicated Scheme in storageprovider with identity types only - Use metav1.ParameterCodec with dedicated Scheme
Clean up debug logging that was added during investigation: - Remove klog.Error debug messages from storageprovider init() - Remove verbose logging from field label conversion functions - Keep only essential code for field selector support All functionality remains intact and tested.
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.
Pass field selectors from REST layer to backend provider to enable staff users to query other users' identities and sessions. This is required for the staff portal to view user identity provider links and active sessions for support purposes.
Changes:
Authorization model:
Security:
This changes the previous 'self-scoped' design where field selectors were intentionally ignored. The new behavior maintains self-scoped access for regular users while enabling cross-user queries for staff.
Because the field selectors are not being passed to the provider, the following error is obtained: