Skip to content

feat: add virtual key and user identity filters to OAuth2 grants sidebar - #5969

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
08-06-feat_add_vk_and_users_filters_to_oauth_grants_sidebar
Aug 8, 2026
Merged

feat: add virtual key and user identity filters to OAuth2 grants sidebar#5969
Pratham-Mishra04 merged 1 commit into
devfrom
08-06-feat_add_vk_and_users_filters_to_oauth_grants_sidebar

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Adds Virtual Key and User identity filters to the OAuth Grants filter sidebar, allowing administrators to scope the grants list to rows belonging to specific virtual keys or users. Because bf_sub is a single generic subject column disambiguated only by bf_mode, each identity filter is paired with its corresponding mode guard (bf_mode = 'vk' or bf_mode = 'user') and the two groups are OR'd together server-side.

Changes

  • Added VirtualKeyIDs and UserIDs fields to OAuth2SessionsQueryParams and the corresponding SQL filter in ListOAuth2Sessions, pairing each ID set with a bf_mode guard so bf_sub lookups are correctly scoped.
  • Extended the HTTP handler and query parser to accept virtual_key_id and user_id as comma-separated query parameters, forwarding them to the store layer.
  • Added VirtualKeyFilterSection and UsersFilterSection components to the OAuth Grants filter sidebar, each using a searchable checkbox list with lazy server-side fetching (only fetches once the section is opened or already has a selection).
  • The Users filter section renders nothing in OSS builds — it depends on an enterprise-registered user search hook via getUserSearchQuery(). If no hook is registered, the section is omitted entirely rather than showing an unresolvable search box.
  • When the Identity mode filter pins to a single mode (e.g. "User"), the opposing picker (e.g. Virtual Key) is hidden and its stale selection is cleared automatically to prevent invisible filtering.
  • URL state is extended with virtual_key_id and user_id array params, included in hasActiveFilters detection and reset logic.
  • The RTK Query API layer sorts and CSV-joins virtual_key_id and user_id arrays to keep the cache key stable regardless of selection order.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

# Core/Transports
go test ./framework/configstore/... ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build
  1. Open the OAuth Grants page and expand the filter sidebar.
  2. Expand the Virtual Key section and search for a key by name — confirm the grants list filters to rows bound to that VK.
  3. Select the User identity mode — confirm the Virtual Key picker disappears and any prior VK selection is cleared.
  4. In an enterprise build, expand the Users section and search by name or email — confirm the grants list filters to rows bound to that user.
  5. In an OSS build, confirm the Users section does not appear.
  6. Confirm that selecting both a VK and a user (with no mode filter) returns rows matching either identity.
  7. Confirm URL state reflects virtual_key_id and user_id params and that the reset button clears them.

Screenshots/Recordings

Add before/after screenshots of the filter sidebar showing the new Virtual Key and Users sections.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

Filters are applied server-side with parameterized IN clauses — no raw user input is interpolated into SQL. The user_id filter is enterprise-only and gated behind the registered user search hook, so OSS deployments have no exposure to user directory data through this surface.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Pratham-Mishra04 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added filtering for OAuth sessions and grants by Virtual Key and user ID.
    • Added searchable, lazy-loaded filter sections with loading and empty-result states.
    • Filter selections synchronize with URL parameters and reset pagination when changed.
    • Virtual Key and user filters work alongside existing mode, search, and pagination options.

Walkthrough

OAuth grants now support virtual-key and user-ID filters. The UI synchronizes selections with URL parameters, the API and HTTP handler forward them, and the config store applies mode-scoped SQL filtering.

Changes

OAuth grant identity filters

Layer / File(s) Summary
UI filter selection and state
ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx, ui/app/workspace/oauth-grants/page.tsx
The sidebar adds searchable Virtual Key and Users sections. Filter selections update URL state, active-filter counts, query parameters, and pagination.
Query serialization and transport
ui/lib/store/apis/oauth2SessionsApi.ts, transports/bifrost-http/handlers/mcpoauth2sessions.go
The API serializes identity arrays as sorted comma-separated parameters. The HTTP handler parses and forwards both filters.
Session query filtering
framework/configstore/store.go, framework/configstore/rdb.go
The query model accepts virtual-key and user-ID filters. SQL applies each filter only to its matching bf_mode, combines identity groups with OR, and preserves existing filters with AND semantics.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OAuthGrantsFilterSidebar
  participant OAuthGrantsPage
  participant oauth2SessionsApi
  participant listSessions
  participant ListOAuth2Sessions
  OAuthGrantsFilterSidebar->>OAuthGrantsPage: select virtual_key_id or user_id
  OAuthGrantsPage->>oauth2SessionsApi: request selected filters
  oauth2SessionsApi->>listSessions: send serialized query parameters
  listSessions->>ListOAuth2Sessions: forward parsed identity filters
  ListOAuth2Sessions-->>OAuthGrantsPage: return filtered OAuth2 sessions
Loading

Possibly related PRs

Suggested reviewers: akshaydeo, danpiths, bearts

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description covers the feature, affected areas, testing steps, security considerations, and breaking changes; screenshots and checklist confirmations remain incomplete.
Title check ✅ Passed The title clearly identifies the main feature: virtual key and user identity filters for the OAuth Grants sidebar.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 08-06-feat_add_vk_and_users_filters_to_oauth_grants_sidebar

Comment @coderabbitai help to get the list of available commands.

Pratham-Mishra04 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Aug 8, 10:33 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 8, 11:34 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 8, 11:35 AM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
transports/bifrost-http/handlers/mcpoauth2sessions.go (1)

80-81: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add table-driven coverage for identity-filter semantics.

Cover virtual-key-only, user-only, both groups with OR semantics, and identity filters combined with bf_mode. Confirm that each identity filter matches only its required mode and does not bypass existing filters.

🤖 Prompt for 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.

In `@transports/bifrost-http/handlers/mcpoauth2sessions.go` around lines 80 - 81,
In transports/bifrost-http/handlers/mcpoauth2sessions.go:80-81, add table-driven
coverage for virtual-key-only, user-only, combined identity filters with OR
semantics, and identity filters combined with bf_mode; verify each filter
matches only its required mode and preserves existing filters. In
framework/configstore/rdb.go:8637-8652, cover the corresponding query/filter
behavior; no production change is requested unless the tests expose incorrect
identity-filter semantics.

Source: Coding guidelines

🤖 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 `@ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx`:
- Around line 347-370: Update the filter sidebar rendering around the search
input and filtered items to show “No results” only when fetching is false.
Propagate query errors from both query sections into this component, distinguish
loading, error, and empty states, and render a retryable error state with the
existing query retry mechanism when a request fails.
- Around line 404-410: Ensure selected virtual keys and users remain rendered
when absent from the current result page by merging or resolving selected IDs
before building each filter’s items. Update the virtual-key filter at
ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx lines 404-410
and the user filter at lines 457-463; both sites require the same selected-item
preservation behavior while retaining current search results.

---

Nitpick comments:
In `@transports/bifrost-http/handlers/mcpoauth2sessions.go`:
- Around line 80-81: In
transports/bifrost-http/handlers/mcpoauth2sessions.go:80-81, add table-driven
coverage for virtual-key-only, user-only, combined identity filters with OR
semantics, and identity filters combined with bf_mode; verify each filter
matches only its required mode and preserves existing filters. In
framework/configstore/rdb.go:8637-8652, cover the corresponding query/filter
behavior; no production change is requested unless the tests expose incorrect
identity-filter semantics.
🪄 Autofix

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: 04de630c-f3c6-48e0-a8a0-969d0f711b93

📥 Commits

Reviewing files that changed from the base of the PR and between 06551aa and 5e6b9eb.

📒 Files selected for processing (6)
  • framework/configstore/rdb.go
  • framework/configstore/store.go
  • transports/bifrost-http/handlers/mcpoauth2sessions.go
  • ui/app/workspace/oauth-grants/page.tsx
  • ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx
  • ui/lib/store/apis/oauth2SessionsApi.ts

Comment on lines +347 to +370
{fetching ? (
<LoaderCircle className="text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 animate-spin" />
) : (
<Search className="text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2" />
)}
<Input
ref={inputRef}
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder={placeholder}
className="h-8 border-0 pl-8 text-xs"
data-testid={testIdPrefix ? `${testIdPrefix}-search` : undefined}
/>
</div>
{filtered.map((item) => (
<CheckboxFilterItem
key={item.key}
label={item.label}
checked={isSelected(item.key)}
onCheckedChange={() => onToggle(item.key)}
testId={testIdPrefix ? `${testIdPrefix}-checkbox-${item.key}` : undefined}
/>
))}
{filtered.length === 0 && <div className="text-muted-foreground flex h-9 items-center px-3 text-xs">No results</div>}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Separate loading, error, and empty states.

When a new search starts, filtered can be empty while fetching is true. The component then shows No results with a loading icon. A failed query also shows No results.

Render the empty state only after loading completes. Pass an error state from both query sections and show a retryable error state.

🤖 Prompt for 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.

In `@ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx` around
lines 347 - 370, Update the filter sidebar rendering around the search input and
filtered items to show “No results” only when fetching is false. Propagate query
errors from both query sections into this component, distinguish loading, error,
and empty states, and render a retryable error state with the existing query
retry mechanism when a request fails.

Sources: Coding guidelines, Path instructions

Comment on lines +404 to +410
items={virtualKeys.map((vk) => ({ key: vk.id, label: vk.name || vk.id }))}
isSelected={(key) => filters.virtual_key_id.includes(key)}
onToggle={toggle}
onSearch={setSearchQuery}
fetching={isFetching}
testIdPrefix="oauth-grants-filter-vk"
/>

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Keep selected entries visible after result pages change.

The current result page is the only source for rendered checkboxes. A selected ID disappears after another search or after reload when it is not in that page. The filter remains active, but the user cannot inspect or clear that ID individually.

  • ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx#L404-L410: Render selected virtual keys separately from the current search page, or resolve selected IDs before rendering.
  • ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx#L457-L463: Render selected users separately from the current search page, or resolve selected IDs before rendering.
📍 Affects 1 file
  • ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx#L404-L410 (this comment)
  • ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx#L457-L463
🤖 Prompt for 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.

In `@ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx` around
lines 404 - 410, Ensure selected virtual keys and users remain rendered when
absent from the current result page by merging or resolving selected IDs before
building each filter’s items. Update the virtual-key filter at
ui/app/workspace/oauth-grants/views/oauthGrantsFilterSidebar.tsx lines 404-410
and the user filter at lines 457-463; both sites require the same selected-item
preservation behavior while retaining current search results.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 08-06-feat_add_virtual_key_and_users_filters_to_mcp_auth_sessions_sidebar to graphite-base/5969 August 8, 2026 11:30
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5969 to dev August 8, 2026 11:33
@Pratham-Mishra04
Pratham-Mishra04 requested a review from a team as a code owner August 8, 2026 11:33
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-06-feat_add_vk_and_users_filters_to_oauth_grants_sidebar branch from 5e6b9eb to 38377ae Compare August 8, 2026 11:33
@Pratham-Mishra04
Pratham-Mishra04 merged commit 4fba9d7 into dev Aug 8, 2026
14 of 15 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 08-06-feat_add_vk_and_users_filters_to_oauth_grants_sidebar branch August 8, 2026 11:35
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.

2 participants