Skip to content

feat(auth): add scoped internal executor delegation - #6459

Merged
TheodoreSpeaks merged 2 commits into
improvement/v2-endpointsfrom
improvement/internal-delegation-foundation
Aug 8, 2026
Merged

feat(auth): add scoped internal executor delegation#6459
TheodoreSpeaks merged 2 commits into
improvement/v2-endpointsfrom
improvement/internal-delegation-foundation

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • add short-lived, subject-bearing executor delegation tokens
  • derive workspace authority from canonical workflow and execution state
  • reject actorless legacy JWTs for migrated workspace operations
  • migrate internal file CSV preview as the first consumer

Type of Change

  • New feature

Testing

  • 19 focused tests
  • sim and @sim/auth type-checks
  • Biome
  • strict API validation
  • full ship audit matrix

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 8, 2026 11:03pm

Request Review

@cursor

cursorBot commented Aug 8, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes authentication and authorization for internal executor access to workspace resources; incorrect binding or audience checks could grant cross-workspace access or break executor file operations.

Overview
Introduces short-lived, subject-bearing executor delegation JWTs (internal_delegation) bound to workflowId and optional executionId, replacing the prior pattern where a generic internal JWT could be turned into a delegated principal using workspace IDs from the URL.

createInternalSessionOrExecutorAuth verifies delegation tokens (not legacy internal or actorless JWTs), then bindInternalExecutorDelegation loads canonical workflow/run context to set workspaceId and WorkflowExecutionDelegatedPrincipal with delegationContext. Stale or missing canonical bindings yield 401; infrastructure errors are not masked as bad credentials. Bearer headers that are not valid Bearer … delegation tokens are rejected instead of falling back to session.

Workspace file internal routes use audience sim:workspace-files and optional fileId resource scope; CSV preview is the first migrated route. @sim/auth adds WorkflowExecutionDelegatedPrincipal typing for executor workflow-execution delegation.

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

@greptile-apps

greptile-appsBot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR introduces short-lived executor delegation tokens and migrates internal CSV preview authentication from legacy internal JWTs to canonically bound workflow/execution principals.

  • Adds strict delegation-token issuance and verification with subject, workflow, lifetime, issuer, audience, and delegation ID claims.
  • Resolves workflow or execution state to its canonical workspace before constructing a delegated principal.
  • Restricts CSV-preview delegation to the requested file while preserving current human workspace-permission checks.
  • Rejects legacy and actorless internal JWTs on the migrated route.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

FilenameOverview
apps/sim/lib/auth/internal.tsAdds strict issuance and verification for short-lived, subject-bearing executor delegation JWTs.
apps/sim/lib/auth/internal-delegation.tsBinds verified workflow or execution claims to the canonical active workspace without trusting route workspace parameters.
apps/sim/lib/api/server/routes/internal-json-route.tsReplaces legacy service-token authentication with executor delegation verification and canonical binding.
apps/sim/lib/workspace-files/api/route-policies.tsDefines the workspace-files delegation audience and narrows delegated access to the requested file ID.
apps/sim/app/api/workspaces/[id]/files/[fileId]/csv-preview/route.tsMigrates CSV preview to session-or-executor authentication while retaining existing operation and error policies.
packages/auth/src/principal.tsAdds the typed workflow-execution context carried by executor delegated principals.

Sequence Diagram

sequenceDiagram
participant Executor
participant Route as CSV Preview Route
participant JWT as Delegation Verification
participant Context as Workflow Context Resolver
participant Authz as Workspace Authorization
participant Files as File Preview Operation
Executor->>Route: Bearer delegation token
Route->>JWT: Verify signature and scoped claims
JWT-->>Route: Subject, workflow, optional execution
Route->>Context: Resolve active workflow/execution
Context-->>Route: Canonical workspace
Route->>Authz: Principal + file scope
Authz->>Authz: Check audience, expiry, workspace, file, current user permission
Authz->>Files: Execute CSV preview
Files-->>Executor: Preview response
Loading

Reviews (2): Last reviewed commit: "fix(auth): derive delegation lifetime fr..." | Re-trigger Greptile

Comment threadapps/sim/lib/auth/internal.ts
@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6288240. Configure here.

@TheodoreSpeaks
TheodoreSpeaks merged commit aae5354 into improvement/v2-endpointsAug 8, 2026
5 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the improvement/internal-delegation-foundation branch August 8, 2026 23:12
Sign up for freeto 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.

1 participant

@TheodoreSpeaks