Skip to content

feat(auth): implement service API key support for session creator in turns API - #1357

Merged
thesujai merged 14 commits into
mainfrom
feat/assume-user-header
Nov 13, 2026
Merged

thesujai merged 14 commits into
mainfrom
feat/assume-user-header

Conversation

@thesujai

@thesujai thesujai commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

…

Summary

Closes AGE-2771

Changes

How was this tested?

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

High Risk
Extends authentication so a service key plus assume-user impersonates the session creator on turn list/create, which is security-sensitive and changes route mounting order.

Overview
Service API keys can now call list turns and create turn on /api/v1/sessions/{session_id}/turns when they send assume-user: session-creator, acting as the session’s creator instead of a JWT user.

The server adds assumeUser handling (applyAssumeUserToContext, resolveTurnRequestContext), mounts turns behind createAuthOrServiceKeyMiddleware (JWT or service key) before JWT-only session routes, and tightens service create-turn to sessions bound to a named agent (no creator-owner check on that path). OpenAPI, Fern, and TypeScript/Python SDK clients expose optional assumeUser on those session methods.

Reviewed by Cursor Bugbot for commit 0658ad1. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0658ad1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Reviews

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/app.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/app.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/apis/turns.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved
Stops a JWT caller from skipping owner and authorizer checks by sending assume-user alone.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread .github/fern/openapi/openapi.json Resolved
Comment thread packages/trueforge/src/app.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/trueforge/src/app.ts Resolved
Comment thread packages/trueforge/src/app.ts Resolved
Comment thread packages/trueforge/src/apis/turns.ts Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 24538a7. Configure here.

Comment thread packages/trueforge/src/apis/turns.ts Resolved
…veRequestContext parameter and clarifying assume-user handling
…RequestContext parameter and improve error handling for missing assume-user header
@thesujai
thesujai enabled auto-merge (squash) November 13, 2026 05:25
@thesujai
thesujai disabled auto-merge November 13, 2026 05:28
@thesujai
thesujai merged commit e41abb3 into main Nov 13, 2026
13 checks passed
@thesujai
thesujai deleted the feat/assume-user-header branch November 13, 2026 05:28
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