Skip to content

session api - #3698

Merged
akshaydeo merged 1 commit into
mainfrom
05-22-session_api
May 22, 2026
Merged

session api#3698
akshaydeo merged 1 commit into
mainfrom
05-22-session_api

Conversation

@akshaydeo

@akshaydeo akshaydeo commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The logout flow now calls both the password-based session logout endpoint and the OAuth logout endpoint, ensuring users are fully signed out regardless of which authentication method they used. Previously, only the password session was terminated on logout.

Changes

  • Replaced the single /session/logout POST call with a queryFn that sequentially calls both /session/logout and /scim/oauth/logout, returning an error only if both fail
  • Added dispatch(baseApi.util.resetApiState()) in the onQueryStarted finalizer to clear all cached RTK Query state after logout, preventing stale data from persisting across sessions

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

  1. Log in using OAuth (SCIM/OAuth provider)
  2. Click logout
  3. Verify the user is redirected to the login page and the OAuth session is also invalidated (no silent re-authentication)
  4. Repeat with a password-based login and confirm logout still works as expected
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

N/A

Security considerations

Ensures OAuth sessions are explicitly terminated on logout, reducing the risk of session persistence after a user signs out. The API state reset also prevents cached sensitive data (keys, budgets, teams, etc.) from being accessible after logout.

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

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Rate limit exceeded

@akshaydeo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 312731bb-f042-4a73-aebb-a59199f07b42

📥 Commits

Reviewing files that changed from the base of the PR and between 7d9e881 and cf63e9d.

📒 Files selected for processing (1)
  • ui/lib/store/apis/sessionApi.ts
📝 Walkthrough

Walkthrough

The PR updates the session logout mutation to coordinate logout across two endpoints (/session/logout and /scim/oauth/logout) and clears the RTK Query cache state afterward.

Changes

Session Logout Flow

Layer / File(s) Summary
Logout Mutation with Dual Endpoints and Cache Clearing
ui/lib/store/apis/sessionApi.ts
Logout mutation uses custom queryFn to perform two sequential POST requests to session and OAuth logout endpoints with combined error handling, and extends onQueryStarted to dispatch baseApi.util.resetApiState() for clearing RTK Query cached state after the request lifecycle completes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • danpiths

Poem

🐰 A logout flows both ways,
Two endpoints cleared in graceful days,
Cache wiped clean, state reset,
Sessions gone—no data left!
Bifrost logout, done just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The code changes in the PR address OAuth logout and API state management for sessions, but the linked issue #123 is about Files API support for providers, which is entirely unrelated to logout functionality. Either link the relevant issues related to session logout improvements, or remove issue #123 if it was linked in error. Ensure the PR's linked issues match its actual objectives.
Title check ❓ Inconclusive The title "session api" is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes made. Revise the title to be more specific and descriptive, such as 'Add OAuth logout and reset API state on session logout' or 'Improve logout flow with OAuth termination and state cleanup'.
Out of Scope Changes check ❓ Inconclusive The PR modifies only the session logout mutation and API state reset, which are in-scope changes. However, the linked issue #123 concerns Files API support, making the PR's scope unclear relative to its linked issues. Clarify the PR's scope by linking to issues that actually relate to session logout improvements, or document why issue #123 is referenced if it is indeed related to this change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is mostly complete, covering summary, changes, type, affected areas, testing steps, security considerations, and breaking changes, though some checklist items are unchecked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-22-session_api

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

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

akshaydeo commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

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

@akshaydeo
akshaydeo marked this pull request as ready for review May 22, 2026 15:00
@coderabbitai
coderabbitai Bot requested a review from danpiths May 22, 2026 15:01
@akshaydeo
akshaydeo changed the base branch from dev to graphite-base/3698 May 22, 2026 15:02
@akshaydeo
akshaydeo force-pushed the 05-22-session_api branch from 7d9e881 to cf63e9d Compare May 22, 2026 15:02
@akshaydeo
akshaydeo force-pushed the graphite-base/3698 branch from f59c88c to 0563140 Compare May 22, 2026 15:02
@akshaydeo
akshaydeo changed the base branch from graphite-base/3698 to main May 22, 2026 15:02

akshaydeo commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • May 22, 3:02 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 22, 3:03 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit 3507c48 into main May 22, 2026
9 of 10 checks passed
@akshaydeo
akshaydeo deleted the 05-22-session_api branch May 22, 2026 15:03
@greptile-apps

greptile-apps Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

Safe to merge; logout cleanup is correct and the OAuth session is now explicitly terminated on sign-out

The core logic — clearing auth storage and resetting RTK Query state on logout — is sound. Both issues are about efficiency and redundancy: sequential vs. parallel API calls, and invalidatesTags coexisting with resetApiState(). Neither prevents correct logout behavior.

ui/lib/store/apis/sessionApi.ts — specifically the invalidatesTags list and the sequential logout calls

Important Files Changed

Filename Overview
ui/lib/store/apis/sessionApi.ts Logout mutation expanded to cover both password and OAuth sessions; two minor issues: sequential instead of parallel calls, and redundant invalidatesTags alongside resetApiState()

Reviews (1): Last reviewed commit: "session api" | Re-trigger Greptile

Comment on lines +44 to +60
async queryFn(_arg, _api, _extraOptions, baseQuery) {
const passwordLogout = await baseQuery({
url: "/session/logout",
method: "POST",
});

const oauthLogout = await baseQuery({
url: "/scim/oauth/logout",
method: "POST",
});

if (passwordLogout.error && oauthLogout.error) {
return { error: oauthLogout.error };
}

return { data: { message: "Logout successful" } };
},

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.

P2 The two logout requests are issued sequentially — /scim/oauth/logout only starts after /session/logout completes. If the password-logout endpoint is slow or temporarily unresponsive, the OAuth session stays active longer than needed, and the user's perceived logout time doubles. Running them in parallel is safe here because neither result depends on the other.

Suggested change
async queryFn(_arg, _api, _extraOptions, baseQuery) {
const passwordLogout = await baseQuery({
url: "/session/logout",
method: "POST",
});
const oauthLogout = await baseQuery({
url: "/scim/oauth/logout",
method: "POST",
});
if (passwordLogout.error && oauthLogout.error) {
return { error: oauthLogout.error };
}
return { data: { message: "Logout successful" } };
},
async queryFn(_arg, _api, _extraOptions, baseQuery) {
const [passwordLogout, oauthLogout] = await Promise.all([
baseQuery({ url: "/session/logout", method: "POST" }),
baseQuery({ url: "/scim/oauth/logout", method: "POST" }),
]);
if (passwordLogout.error && oauthLogout.error) {
return { error: oauthLogout.error };
}
return { data: { message: "Logout successful" } };
},

dispatch(baseApi.util.resetApiState());
}
},
invalidatesTags: ["Sessions", "Config", "Providers", "Logs", "VirtualKeys", "Teams", "Customers", "Budgets", "RateLimits"],

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.

P2 invalidatesTags is redundant here. dispatch(baseApi.util.resetApiState()) already wipes the entire RTK Query cache — a strict superset of what tag invalidation does. Having both means RTK Query will first try to trigger refetches for every subscribed query matching these tags (potentially sending unauthenticated requests since clearAuthStorage() runs in the same finally block), and then resetApiState() immediately cancels and clears them. Removing invalidatesTags eliminates that brief window of spurious requests.

Suggested change
invalidatesTags: ["Sessions", "Config", "Providers", "Logs", "VirtualKeys", "Teams", "Customers", "Budgets", "RateLimits"],
// invalidatesTags removed: resetApiState() in onQueryStarted already clears the full cache

Vaibhav701161 pushed a commit that referenced this pull request May 26, 2026
## Summary

The logout flow now calls both the password-based session logout endpoint and the OAuth logout endpoint, ensuring users are fully signed out regardless of which authentication method they used. Previously, only the password session was terminated on logout.

## Changes

- Replaced the single `/session/logout` POST call with a `queryFn` that sequentially calls both `/session/logout` and `/scim/oauth/logout`, returning an error only if both fail
- Added `dispatch(baseApi.util.resetApiState())` in the `onQueryStarted` finalizer to clear all cached RTK Query state after logout, preventing stale data from persisting across sessions

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

1. Log in using OAuth (SCIM/OAuth provider)
2. Click logout
3. Verify the user is redirected to the login page and the OAuth session is also invalidated (no silent re-authentication)
4. Repeat with a password-based login and confirm logout still works as expected

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

## Screenshots/Recordings

N/A

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

N/A

## Security considerations

Ensures OAuth sessions are explicitly terminated on logout, reducing the risk of session persistence after a user signs out. The API state reset also prevents cached sensitive data (keys, budgets, teams, etc.) from being accessible after logout.

## 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
@akshaydeo akshaydeo mentioned this pull request May 26, 2026
akshaydeo added a commit that referenced this pull request May 26, 2026
## ✨ Features

- **Azure v1 API Migration** — Migrated Azure provider to the v1 API:
removed the `api-version` query parameter and the
`/openai/deployments/{model}/...` URL pattern in favor of
`/openai/v1/{operation}`; the `api_version` field has been dropped from
`AzureKeyConfig` (#3661, #3756)
- **EnvVar Support for OTEL & Prometheus Configs** — `CollectorURL`,
`MetricsEndpoint`, headers, push gateway URL, and basic auth credentials
can now be sourced from environment variables (e.g.,
`env.OTEL_COLLECTOR_URL`); added a new `ConfigMarshallerPlugin`
interface that lets plugins control storage/redaction round-trips
(#3651)
- **OTel Extra Header Forwarding** — `x-bf-eh-*` extra headers forwarded
to upstream providers are now also emitted on the request span under
`gen_ai.request.extra_header.*` for end-to-end tracing (#3730)
- **OTel Semantic Conventions** — Aligned OTel attribute keys with the
OpenTelemetry GenAI spec (canonical `gen_ai.*` and new `bifrost.*`
attributes); legacy attributes are retained in parallel to avoid
breaking existing dashboards (#3732)
- **VK Quota with Provider Configs** — `GetVirtualKeyQuotaByValue` and
the `getVirtualKeyQuota` HTTP response now include `provider_configs`
with their budgets and rate limits (#3721)
- **MCP Temp Token Non-Auth Toggle** — Added
`mcp_enable_temp_token_auth` client config flag to gate short-lived MCP
token minting for non-authenticated users (#3720)
- **Responses Stream in JSON Parser** — `jsonparser` plugin now handles
OpenAI Responses API streaming (`ResponsesStreamRequest`) in addition to
chat completions (#3749)
- **Session API Rework** — Logout now calls both the password-based
session logout and OAuth logout endpoints and resets all RTK Query cache
state (#3698)

## 🐞 Fixed

- **Streaming Latency for Observability** — Deferred root span
termination to the trace completer callback for streaming requests so
request latency is no longer inflated by header-flush time (#3762)
- **Stream Cancellation Race** — Set `BifrostContextKeyConnectionClosed`
before closing the stream and short-circuit `idleTimeoutReader.Read`
when the connection is already closed to avoid panics and hangs on
cancellation (#3733)
- **Bedrock Cache Points** — Strip cache points from Bedrock requests
for models that do not support prompt caching (e.g., GLM, Llama) to
avoid Converse API errors (#3754)
- **Bedrock Empty Text Blocks** — Skip empty/nil text blocks during
Bedrock response conversion to avoid invalid messages (#3747)
- **Bedrock Reasoning + Tools** — Preserve reasoning content blocks on
assistant turns that also contain tool calls in the Bedrock chat
converter (#3690)
- **Bedrock Search Content & Video** — Restored search content and video
parts that were being dropped from Bedrock-native passthrough requests
(#3729)
- **Structured Output Stop Reason** — Fixed an incorrect `tool_calls`
finish reason when structured output is combined with extended-thinking
tools (#3685)
- **Gemini Tool Schema Passthrough** — Forward full tool parameter
schemas via `parametersJsonSchema` instead of the lossy `parameters`
form; corrected tool response role to `user`; resolved structured output
+ tools conflict (#3761)
- **Anthropic Stop Reason & Tool Versions** — Normalized stop reason
mapping (`end_turn` to `stop`, `tool_use` to `tool_calls`, `max_tokens`
to `length`) and upgraded `text_editor_20250124`/`str_replace_editor` to
`text_editor_20250728` for computer-use tools (#3761)
- **Azure Endpoint Redaction** — Fixed a panic when
`AzureKeyConfig.Endpoint` is a literal value rather than an env
reference (#3761)
- **Auth Middleware Path Match** — Match temp-token auth middleware
whitelist against the request path only, not the full URI with query
parameters (#3737)
- **Governance Blocked Models UI** — Restored the missing Blocked Models
create/edit UI in the VK provider config sheet (#3750)
- **Logging Plugin Cleanup Drain** — Fixed a shutdown race where
`batchWriter` could drop in-flight log entries; `Cleanup` now drains
both the recovered batch and remaining queue within a 30-second budget
(#3717)
- **Model Rankings Empty Entries** — Excluded entries with empty `model`
values from model rankings matview queries so blank rows no longer
surface in the UI (#3758)
- **User Filter Duplicates** — Recreated `mv_filter_users` matview to
require non-empty `user_name`, eliminating duplicate filter dropdown
entries (#3764)
- **User Filter Display Name** — Use `user_name` instead of `user_id` as
the display label for users in logging filters (#3691)
- **Large Numeric ID Precision** — Preserve large numeric IDs in URL
search params by skipping JSON parsing for plain strings (#3692)

## 🔧 Refactors & Chores

- **Error Propagation for GetAvailable\* APIs** — `GetAvailable*`
methods on `LoggerPlugin`/`LogManager` now return wrapped errors instead
of silently logging and returning empty slices (#3759)
- **Governance Blocklist Matching** — Use `slices.Contains` for VK
blocked-model matching for clearer code with identical semantics (#3727)
- **Exported `ResolvePeriod`** — Renamed `resolvePeriod` to
`ResolvePeriod` so external packages can reuse the period parsing
(#3763)

## 📚 Docs

- **OTEL Env Var Documentation** — Documented `env.VAR_NAME` support for
`collector_url`, `metrics_endpoint`, and headers in OTEL/Prometheus
plugin docs
- **OTEL OSS Features & Examples** — Added OTEL documentation to the OSS
features list with usage examples (#3731)
- **Anthropic Auth Recommendation** — Recommend `ANTHROPIC_AUTH_TOKEN`
over `ANTHROPIC_CUSTOM_HEADERS` for Claude Code authentication (#3686)
@akshaydeo akshaydeo mentioned this pull request May 27, 2026
18 tasks
akshaydeo added a commit that referenced this pull request May 27, 2026
## Summary

This PR releases Bifrost OSS `v1.5.5` and Enterprise `v1.4.4`, bumping all module pins from `v1.5.12`/`v1.3.12` to `v1.5.13`/`v1.3.13` across core, framework, and all plugins. It also hardens the Docker manifest shell scripts, expands CI egress allowlists, and updates documentation to reflect the new SCIM-based user provisioning feature.

## Changes

- **Module version bumps**: All `go.mod`/`go.sum` files updated from `core v1.5.12` → `v1.5.13`, `framework v1.3.12` → `v1.3.13`, and all plugin versions incremented accordingly (`compat`, `governance`, `jsonparser`, `logging`, `maxim`, `mocker`, `otel`, `prompts`, `semanticcache`, `telemetry`).
- **Docker manifest scripts**: Added `#!/usr/bin/env bash` shebang and `set -euo pipefail` to `create-docker-manifest.sh` and `create-docker-manifest-ubi9.sh`; quoted all variable expansions and switched `jq -r` to `jq -er` to fail on null digests.
- **CI egress allowlist**: Added `production.cloudfront.docker.com:443` to Docker-related job allowlists, and added `_https._tcp.dl.google.com:443` and `motd.ubuntu.com:443` to the Ubuntu package job allowlist.
- **Changelog files**: Cleared per-module `changelog.md` files (content moved into the new versioned docs). Added `docs/changelogs/v1.5.5.mdx` and `docs/changelogs/ent-v1.4.4.mdx` with full release notes, and registered both in `docs/docs.json`.
- **Documentation**: Replaced the SSO Integration link with a User Provisioning (SCIM) link in both `README.md` and `transports/README.md`.
- **Enterprise v1.4.4 highlights** (documented): Kafka and Google Cloud Pub/Sub observability sinks, chunked streaming with a 100 MB inter-node message ceiling, BigQuery custom labels via env vars using the new `ConfigMarshallerPlugin` interface, temporary access token expiry extensions, and a multi-node cluster integration harness.
- **OSS v1.5.5 highlights** (documented): Azure v1 API migration, env-var support for OTel/Prometheus configs, OTel extra-header forwarding and semantic-convention alignment, virtual key quota including provider configs, Responses API streaming in `jsonparser`, and a batch of Bedrock, Gemini, Anthropic, Azure, and logging plugin fixes.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [x] Documentation
- [x] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [x] Plugins
- [ ] UI (React)
- [x] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# Verify Docker manifest scripts exit on error
bash -n .github/workflows/scripts/create-docker-manifest.sh
bash -n .github/workflows/scripts/create-docker-manifest-ubi9.sh
```

Validate that the new changelog pages (`changelogs/v1.5.5` and `changelogs/ent-v1.4.4`) render correctly in the docs site.

## Screenshots/Recordings

N/A

## Breaking changes

- [x] Yes
- [ ] No

The Azure provider no longer accepts `api_version` in `AzureKeyConfig` and has migrated to the `/openai/v1/{operation}` URL pattern. See the [v1.4.0 Migration Guide](https://docs.getbifrost.ai/enterprise/migration-guides/v1.4.0) for full details.

## Related issues

#3661, #3756, #3651, #3730, #3732, #3754, #3747, #3690, #3729, #3685, #3733, #3761, #3735, #3721, #3720, #3749, #3698, #3762, #3750, #3727, #3717, #3759, #3758, #3764, #3691, #3692, #3737, #3763

## Security considerations

- The `ConfigMarshallerPlugin` interface redacts secrets (OTel collector URLs, Prometheus push gateway credentials, BigQuery labels) at config storage time and rehydrates them at load time, preventing plaintext secret persistence.
- Docker manifest scripts now use `set -euo pipefail`, preventing silent failures that could result in malformed or missing image manifests being pushed.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
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