feat: add user_id filter to virtual keys list (enterprise-only, OSS fails closed) - #5653
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
🚧 Files skipped from review as they are similar to previous changes (11)
📝 WalkthroughSummary by CodeRabbit
WalkthroughVirtual-key listing now supports an optional enterprise-only ChangesVirtual-key user filtering
API and UI supporting updates
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Page as GovernanceVirtualKeysPage
participant Table as VirtualKeysTable
participant API as governanceApi.getVirtualKeys
participant Handler as getVirtualKeys
participant Store as GetVirtualKeysPaginated
Page->>Table: pass userFilter
Table->>API: request user_id
API->>Handler: send user_id
Handler->>Store: pass UserID
Store-->>Handler: return filtered virtual keys
Handler-->>API: return response
API-->>Table: render results
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@framework/configstore/rdb.go`:
- Around line 3275-3294: The assignment filtering flow should fail closed
immediately for OSS UserID queries. In the method containing the
assignmentClauses construction, return an empty result set before adding
customer or team clauses whenever params.UserID is set; remove the 1 = 0 clause,
and add table-driven tests covering user-only and user-plus-customer/team
combinations.
In `@transports/bifrost-http/handlers/governance.go`:
- Around line 1193-1207: Update the virtual-key GET handler so userID is honored
when from_memory=true instead of bypassed by the in-memory early return. Apply
the user_id filter to the cached-key path, or explicitly reject the combination
with a documented 400 response; preserve existing behavior for other query
modes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: afd1af34-d45c-4abc-89ec-7d733753e435
📒 Files selected for processing (9)
docs/openapi/paths/management/governance.yamlframework/configstore/rdb.goframework/configstore/store.gotransports/bifrost-http/handlers/governance.goui/app/workspace/governance/virtual-keys/page.tsxui/app/workspace/virtual-keys/views/virtualKeysTable.tsxui/lib/registries/userPicker.tsxui/lib/store/apis/governanceApi.tsui/lib/types/governance.ts
6d732fb to
b33deeb
Compare
b33deeb to
1d8cf3a
Compare
Merge activity
|

Summary
Adds a
user_idquery parameter to the virtual keys list endpoint, allowing callers to filter virtual keys by their assigned user. Because the virtual key–user relationship lives in an enterprise-only table, the OSS build fails closed (matches no keys) rather than silently returning unfiltered results. The enterprise store overrides the base implementation to honour the filter correctly.Changes
user_idquery parameter to theGET /virtual-keysOpenAPI spec, documented as enterprise-only and combined withcustomer_id/team_idusing OR logic.GetVirtualKeysPaginatedfrom a chain of if/else branches into a slice-based OR builder, making it straightforward to add theuser_idclause. In the OSS build, a non-emptyuser_idinjects1 = 0to ensure no rows are returned.UserIDtoVirtualKeyQueryParamswith a comment clarifying its OSS behaviour.user_idthrough the HTTP handler query arg parsing and into the params struct.user_idURL state, filter prop threading, and ahandleUserFilterChangecallback in the virtual keys page.UserPickercomponent in the virtual keys table filter bar when a picker is registered (enterprise builds). The picker is hidden entirely in OSS builds where no picker is registered. An "or" label appears between the team/customer filters and the user filter when multiple assignment filters are active.UserPickerPropswithplaceholder,className, andtriggerClassNameto support use as a filter control.user_idtoGetVirtualKeysParamsand the RTK Query API call.Type of change
Affected areas
How to test
OSS build — user_id filter fails closed:
Enterprise build — user_id filter returns matching keys:
UI (enterprise build): Navigate to Governance → Virtual Keys. A user picker filter should appear in the filter bar. Selecting a user filters the table; clearing it restores the full list. The "or" label should appear between the team/customer filter and the user filter when both are active.
UI (OSS build): The user picker filter should not appear in the filter bar.
Breaking changes
Related issues
Security considerations
The OSS implementation explicitly returns no results when
user_idis supplied, preventing any accidental data exposure from an unimplemented filter being silently ignored. The enterprise override is responsible for enforcing its own access control on the user-scoped query.Checklist
docs/contributing/README.mdand followed the guidelines