Skip to content

feat(database,rbac): add multiple environment API key foundations - #4388

Open
carderne wants to merge 5 commits into
mainfrom
feat/multi-keys-foundations
Open

feat(database,rbac): add multiple environment API key foundations#4388
carderne wants to merge 5 commits into
mainfrom
feat/multi-keys-foundations

Conversation

@carderne

@carderne carderne commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the storage model and authorization contracts needed for multiple environment API keys. Credentials are represented by hashed values, revocation and expiration state, and persisted effective scopes.

The built-in authorization fallback exposes full-access policy preparation, while optional authorization extensions can supply additional presets and task-aware scope generation. This change does not create, display, or authenticate additional keys.

Feature notes

  • Keys outlive their creator's org membership. i.e. when a team member is removed, we have onDelete: SetNull so the API key will persist with no Created By.

Deployment notes

Apply the database migration before deploying code that authenticates or creates additional keys. The new table and contracts are otherwise inert, so this can be deployed and verified without changing existing root-key or public-token behavior.

Follow-ups

  • Confirm the migration has completed before deploying additional-key authentication.
  • Confirm the fallback only prepares explicit full-access policies when no authorization extension is installed.

@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 89167bc

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

This PR includes changesets to release 26 packages
Name Type
@trigger.dev/core Patch
@trigger.dev/sdk Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@trigger.dev/sso Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/dashboard-agent Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer 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

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 192e1846-7719-4f81-ba1f-95e327cc849b

📥 Commits

Reviewing files that changed from the base of the PR and between 51e1189 and 89167bc.

📒 Files selected for processing (1)
  • .changeset/jwt-payload-helpers.md
📜 Recent review details
⏰ Context from checks skipped due to timeout. (31)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
  • GitHub Check: sdk-compat / Node.js 22.23 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 12)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - npm)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
  • GitHub Check: sdk-compat / Node.js 20.20 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
  • GitHub Check: sdk-compat / Node.js 26.4 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: sdk-compat / Node.js 24.18 (warp-ubuntu-latest-x64-4x)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
  • GitHub Check: sdk-compat / Cloudflare Workers
  • GitHub Check: packages / 🧪 Unit Tests: Packages (2, 3)
  • GitHub Check: packages / 🧪 Unit Tests: Packages (3, 3)
  • GitHub Check: sdk-compat / Deno Runtime
  • GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
  • GitHub Check: sdk-compat / Bun Runtime
  • GitHub Check: typecheck / typecheck
  • GitHub Check: internal / 🧪 Unit Tests: Internal
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: runops-guard / runops-guard
  • GitHub Check: 🛡️ E2E Auth Tests (full)
🔇 Additional comments (1)
.changeset/jwt-payload-helpers.md (1)

1-5: LGTM!


Walkthrough

The change adds environment-prefixed API-key generation, hashing, obfuscation, persistence, and database relations. RBAC contracts now support API-key subjects, policy presets, scope parsing, and scope validation. Host controllers normalize optional policy capabilities with fallback defaults and fail-closed preparation. JWT helpers identify public tokens and extract subjects, while changeset documentation specifies expiration timestamps in Unix seconds.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it does not follow the repository template and omits Closes #, checklist, testing, changelog, and screenshots. Rewrite the PR body to match the template: add Closes #, the checklist, testing steps, a changelog summary, and screenshots if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding multi-environment API key foundations across database and RBAC.
Docstring Coverage ✅ Passed Docstring coverage is 80.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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/multi-keys-foundations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@carderne
carderne force-pushed the feat/multi-keys-foundations branch from 0e70a0b to d20a5af Compare July 27, 2026 11:51
@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@51e1189

trigger.dev

npm i https://pkg.pr.new/trigger.dev@51e1189

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@51e1189

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@51e1189

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@51e1189

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@51e1189

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@51e1189

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@51e1189

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@51e1189

commit: 51e1189

@carderne
carderne marked this pull request as ready for review July 27, 2026 14:21

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Base automatically changed from feat/multi-keys-sdk to main July 27, 2026 15:19
carderne added 4 commits July 27, 2026 16:22
A number passed to `expirationTime` is a Unix timestamp in seconds, not
milliseconds as the JSDoc claimed. Following the old docs produced a token
that effectively never expired.

Also fail loudly when an additional API key reaches a local self-signing
fallback. Those keys are not the environment's JWT signing material, so the
token would never verify. Every endpoint that returns a public access token
sets `x-trigger-jwt`, so this is unreachable today.
The API-key policy methods are capability extensions, so declare them
optional on RoleBaseAccessController and normalize the surface in
LazyController rather than requiring every implementation to carry them.

An authorization extension is compiled against whichever core commit its
base image ships, so a required additive method forces both sides to move
together and turns rolling an extension back into a build failure instead
of a graceful degradation.

Absence fails closed: no preset catalogue, and prepareApiKeyPolicy refuses
outright rather than defaulting to full access, so an extension below this
contract cannot mint a credential. Keys already issued are unaffected —
they authorize from the scopes persisted on their row.

loader.create() now returns HostRbacController, the total surface, so host
callers neither guard nor invent their own absent-extension default.
@carderne
carderne force-pushed the feat/multi-keys-foundations branch from 36f03ba to 51e1189 Compare July 27, 2026 15:22
github-advanced-security[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

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