feat(cli,webapp): allow deploys with environment API keys - #4561
feat(cli,webapp): allow deploys with environment API keys#4561carderne wants to merge 8 commits into
Conversation
🦋 Changeset detectedLatest commit: 4a0506f The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe change adds shared bearer-authentication options with preview-parent support. The webapp adds private API-key and project-environment bootstrap authentication. Branch creation and archive routes accept scoped API keys with project, environment, branch, and organization restrictions. API-key scopes now include preview branches. The CLI supports 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
Observability mapAs of Nothing in this pull request moves the report any more. The findings an earlier push reported are gone. The score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md. |
224d15c to
e4e134a
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts (1)
83-113: 🔒 Security & Privacy | 🔴 Critical | ⚡ Quick winBind API-key archive requests to the key environment.
The API-key path filters the target only by organization. An API key for project A can use a project B
projectRefin the same organization and archive its Preview branch. The credential check at Lines 67-79 validates the key environment, but it does not constrain the selected target environment.ArchiveBranchServicecannot enforce this later because it receives onlyorgFilterandenvironmentId.For API-key authentication, add a target predicate that requires the branch
parentEnvironmentIdto equalapiKeyEnvironment.id. This also binds the branch to the key project. Add coverage for sibling projects and sibling root Preview environments.Proposed fix
where: { organization: organizationFilter, + ...(authenticationResult.type === "apiKey" + ? { parentEnvironmentId: apiKeyEnvironment!.id } + : {}), // Dev branches are per-org-member: only the owner may archive their own.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 64dc7b06-0334-412b-8f06-87ec0808bd41
📒 Files selected for processing (3)
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.tspackages/cli-v3/src/deploy/auth.test.tspackages/cli-v3/src/deploy/auth.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/cli-v3/src/deploy/auth.test.ts
- packages/cli-v3/src/deploy/auth.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (19)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (12, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (11, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 12)
- GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 12)
- GitHub Check: runops-guard / runops-guard
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-ubuntu-latest-x64-4x - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (warp-windows-latest-x64-8x - pnpm)
- GitHub Check: internal / 🧪 Unit Tests: Internal
- GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
- GitHub Check: packages / 🧪 Unit Tests: Packages (1, 3)
- GitHub Check: typecheck / typecheck
- GitHub Check: code-quality / code-quality
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: 🛡️ E2E Auth Tests (full)
- GitHub Check: Build and publish previews
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead
**/*.{ts,tsx}: Prefer static imports over dynamicimport(); use dynamic imports only for unresolvable circular dependencies, genuine performance code splitting, or conditional runtime loading.
Import Trigger.dev tasks from@trigger.dev/sdk; never use@trigger.dev/sdk/v3or deprecatedclient.defineJob.
Add agentcrumbs while writing code using approved namespaces; mark lines with//@Crumbsor blocks with `// `#region` `@crumbs, and strip them before merging.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use zod for validation in packages/core and apps/webapp
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use function declarations instead of default exports
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/otel-metrics.mdc)
**/*.ts: When creating or editing OTEL metrics (counters, histograms, gauges), ensure metric attributes have low cardinality by using only enums, booleans, bounded error codes, or bounded shard IDs
Do not use high-cardinality attributes in OTEL metrics such as UUIDs/IDs (envId, userId, runId, projectId, organizationId), unbounded integers (itemCount, batchSize, retryCount), timestamps (createdAt, startTime), or free-form strings (errorMessage, taskName, queueName)
When exporting OTEL metrics via OTLP to Prometheus, be aware that the exporter automatically adds unit suffixes to metric names (e.g., 'my_duration_ms' becomes 'my_duration_ms_milliseconds', 'my_counter' becomes 'my_counter_total'). Account for these transformations when writing Grafana dashboards or Prometheus queries
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
apps/webapp/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/webapp.mdc)
apps/webapp/**/*.{ts,tsx}: Access environment variables through theenvexport ofenv.server.tsinstead of directly accessingprocess.env
Use subpath exports from@trigger.dev/corepackage instead of importing from the root@trigger.dev/corepathDo not reintroduce the removed v1 execution path;
RunEngineVersion.V1branches may only reject or finalize gracefully so v3 clients receive a clean 4xx, never a 5xx.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
apps/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
For apps, use
typecheckfor verification and never usebuildas the correctness check.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
apps/webapp/app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/**/*.{ts,tsx}: For dashboard changes, visually verify the running Remix app with Chrome DevTools MCP, using snapshots, screenshots, interaction, and console-message checks as appropriate.
UseuseCallbackanduseMemoonly for context provider values, expensive derived data used as a dependency, or stable references required by dependency arrays; do not wrap ordinary event handlers or trivial computations.
Use named constants for sentinel or placeholder values instead of scattering raw string literals across comparisons.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
apps/webapp/app/routes/**/*.ts
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/routes/**/*.ts: Use Remix flat-file route conventions with dot-separated segments; for example,api.v1.tasks.$taskId.trigger.tsmaps to/api/v1/tasks/:taskId/trigger.
PAT-authenticated API routes must resolve their target organization or project within the caller's membership scope, using a membership filter or a helper such asfindProjectByReforresolveOrganizationForApiUser; RBAC authorization alone is insufficient.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
apps/webapp/app/**/*.ts
📄 CodeRabbit inference engine (apps/webapp/CLAUDE.md)
apps/webapp/app/**/*.ts: Never userequest.signalto detect client disconnects. UsegetRequestAbortSignal()fromapp/services/httpAsyncStorage.server.ts, which is wired to Express response close events.
Access environment variables through theenvexport fromapp/env.server.ts; never useprocess.envdirectly.
Always use PrismafindFirstinstead offindUnique.
Always use the$transactionhelper from~/db.server, never callprisma.$transactionor$replica.$transactiondirectly. Pass isolation levels as strings, useSerializablefor correctness-critical read-then-write invariants, and guard possibly undefined helper results when a definite value is required.
Files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
🧠 Learnings (12)
📚 Learning: 2026-03-22T13:26:12.060Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3244
File: apps/webapp/app/components/code/TextEditor.tsx:81-86
Timestamp: 2026-03-22T13:26:12.060Z
Learning: In the triggerdotdev/trigger.dev codebase, do not flag `navigator.clipboard.writeText(...)` calls for `missing-await`/`unhandled-promise` issues. These clipboard writes are intentionally invoked without `await` and without `catch` handlers across the project; keep that behavior consistent when reviewing TypeScript/TSX files (e.g., usages like in `apps/webapp/app/components/code/TextEditor.tsx`).
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-03-22T19:24:14.403Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 3187
File: apps/webapp/app/v3/services/alerts/deliverErrorGroupAlert.server.ts:200-204
Timestamp: 2026-03-22T19:24:14.403Z
Learning: In the triggerdotdev/trigger.dev codebase, webhook URLs are not expected to contain embedded credentials/secrets (e.g., fields like `ProjectAlertWebhookProperties` should only hold credential-free webhook endpoints). During code review, if you see logging or inclusion of raw webhook URLs in error messages, do not automatically treat it as a credential-leak/secrets-in-logs issue by default—first verify the URL does not contain embedded credentials (for example, no username/password in the URL, no obvious secret/token query params or fragments). If the URL is credential-free per this project’s conventions, allow the logging.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma error P1001 ("Can't reach database server") in TypeScript, don’t assume a single error shape. Prisma can surface P1001 via two different error classes/fields: `PrismaClientKnownRequestError` exposes it as `err.code === "P1001"` (common during mid-query connection drops), while `PrismaClientInitializationError` exposes it as `err.errorCode === "P1001"` (common on client startup failure). Therefore, predicates should use `err.code === "P1001" || err.errorCode === "P1001"`. Do not flag `err.code === "P1001"` as “unreachable/never matches,” as it is expected in production.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-05-18T08:21:27.694Z
Learnt from: d-cs
Repo: triggerdotdev/trigger.dev PR: 3632
File: apps/webapp/sentry.server.ts:4-21
Timestamp: 2026-05-18T08:21:27.694Z
Learning: When handling Prisma errors for P1001 ("Can't reach database server"), do not assume it only appears under a single property name. Prisma may surface P1001 via either `PrismaClientKnownRequestError` (`err.code === "P1001"`, e.g., mid-query connection drops) or `PrismaClientInitializationError` (`err.errorCode === "P1001"`, e.g., client startup connection failure). To reliably detect the condition, check `err.code === "P1001" || err.errorCode === "P1001"`, and avoid review rules that would incorrectly flag `err.code === "P1001"` as unreachable/never-matching.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-13T19:53:13.759Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3937
File: packages/trigger-sdk/skills/realtime-and-frontend/SKILL.md:258-260
Timestamp: 2026-06-13T19:53:13.759Z
Learning: When reviewing code that uses `trigger.dev/react-hooks`’s `useRealtimeRun`, preserve the call signature where the first argument is the full realtime handle object (not `handle.id`). This is intentional to maintain type-safety and is consistent with the official docs; do not suggest changing the first argument from the handle object to `handle.id`.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-17T17:13:49.929Z
Learnt from: matt-aitken
Repo: triggerdotdev/trigger.dev PR: 3948
File: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.bulk-actions.$bulkActionParam/route.tsx:48-62
Timestamp: 2026-06-17T17:13:49.929Z
Learning: In triggerdotdev/trigger.dev, within `dashboardLoader`/`dashboardAction` (or similar context resolver code) whenever you resolve an organization ID from an organization slug for RBAC/enterprise authorization scope, always read from the primary Prisma client (`prisma`), not `$replica`. Using `$replica` can hit replica-lag and cause the RBAC lookup/authorization to run without the correct org scope (bypassing intended role enforcement). Implement the slug→org lookup with `prisma.organization.findFirst(...)` (or equivalent primary-client query) and add an inline comment documenting why the primary client is required (replica lag could lead to unscoped RBAC checks).
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-23T13:04:21.413Z
Learnt from: carderne
Repo: triggerdotdev/trigger.dev PR: 4023
File: apps/webapp/app/services/upsertBranch.server.ts:14-18
Timestamp: 2026-06-23T13:04:21.413Z
Learning: In TypeScript, it’s valid to `import { type X }` and then use `typeof X` in a type-only position, e.g. `type Alias = z.infer<typeof X>`. The `type` modifier suppresses the runtime import, but the type checker still has the full exported type so `z.infer<typeof X>` can resolve correctly. In code reviews, don’t flag this as a TypeScript compile error as long as `typeof X` is used in a type context (e.g., with `z.infer`, `type` aliases, generics), not as a runtime value.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-05-12T21:04:05.815Z
Learnt from: ericallam
Repo: triggerdotdev/trigger.dev PR: 3542
File: apps/webapp/app/components/sessions/v1/SessionStatus.tsx:1-3
Timestamp: 2026-05-12T21:04:05.815Z
Learning: In this Remix + TypeScript codebase, do not flag a server/client boundary violation when a file imports only types from a module matching `*.server`.
Specifically, it’s safe to import types using `import type { Foo } from "*.server"` or `import { type Foo } from "*.server"` because TypeScript erases type-only imports at compile time and they emit no JavaScript, so they won’t cross the Remix server/client bundle boundary.
Only raise the boundary concern for value imports (e.g., `import { Foo }` without `type`, or `import Foo`), since those produce JavaScript output.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-25T18:21:51.905Z
Learnt from: carderne
Repo: triggerdotdev/trigger.dev PR: 4039
File: apps/webapp/app/routes/invite-revoke.tsx:0-0
Timestamp: 2026-06-25T18:21:51.905Z
Learning: During the Zod v4 migration in the triggerdotdev/trigger.dev webapp, ensure any imports from `conform-to/zod` use the Zod-4 subpath: `conform-to/zod/v4` (e.g., `import { parseWithZod } from "conform-to/zod/v4"`). Do not import from the package root `conform-to/zod`, because it is the Zod 3 implementation and may load Zod-3-only symbols (e.g., `ZodBranded`, `ZodEffects`), which can throw at module load (notably with `zod4.4.3`). This should be enforced across `apps/webapp/**/*` where helpers like `parseWithZod` and `conformZodMessage` are used.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-07-03T17:10:21.498Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 4148
File: apps/webapp/app/models/orgMember.server.ts:149-168
Timestamp: 2026-07-03T17:10:21.498Z
Learning: In triggerdotdev/trigger.dev, `User.email` (Prisma schema: `internal-packages/database/prisma/schema.prisma`) currently does NOT use `citext` and does NOT have a `lower(email)` functional unique index. Therefore, do not introduce Prisma queries like `where: { email: { equals: <value>, mode: "insensitive" } }` (or any case-insensitive lookup) against `User.email`, because it can force sequential scans of the `users` table under load. During review, ensure email is normalized (e.g., lowercased/trimmed) before both writes and subsequent lookups, and if true case-insensitive behavior/uniqueness is required, implement it via a separate app-wide migration (e.g., switch to `citext` and/or add a functional unique index with backfill) rather than bolting it onto individual feature PRs.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-04T18:16:35.386Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 3836
File: apps/supervisor/src/backpressure/backpressureMonitor.ts:3-5
Timestamp: 2026-06-04T18:16:35.386Z
Learning: When reviewing TypeScript in this repo, apply the rule “prefer type aliases over interfaces” only to data/object shapes and union/intersection type modeling. If an interface is being used as a behavioral contract for collaborators to implement (e.g., method-shape interfaces that define required behavior, such as `BackpressureLogger` / `BackpressureSignalSource` in `apps/supervisor/src/backpressure/backpressureMonitor.ts`), keep it as an `interface` and do not flag it as a type-alias-vs-interface violation.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
📚 Learning: 2026-06-09T17:58:04.699Z
Learnt from: 0ski
Repo: triggerdotdev/trigger.dev PR: 3879
File: apps/webapp/app/models/vercelIntegration.server.ts:619-630
Timestamp: 2026-06-09T17:58:04.699Z
Learning: In this codebase, outbound raw `fetch` calls should typically rely on Node/undici’s default request timeout (about ~300s) rather than adding a per-call `AbortController` + `setTimeout` wrapper inside individual functions (e.g. in files like `apps/webapp/app/models/vercelIntegration.server.ts`). During code review, do not flag the absence of a per-call timeout on a single `fetch` as an issue; if per-call timeouts are needed, they should be implemented via a codebase-wide convention (e.g., a shared fetch wrapper or documented pattern) rather than ad-hoc per-function changes.
Applied to files:
apps/webapp/app/routes/api.v1.projects.$projectRef.branches.archive.ts
| const authConfig = readAuthConfigProfile(profile); | ||
| const resolvedApiUrl = apiUrl ?? authConfig?.apiUrl ?? CLOUD_API_URL; |
There was a problem hiding this comment.
🟡 Deploying to a self-hosted server with an environment API key silently targets the public cloud
The saved profile's server address is only used when no address is supplied (apiUrl ?? authConfig?.apiUrl at packages/cli-v3/src/deploy/auth.ts:43), but the deploy command always supplies one because the command-line option defaults to the public cloud address, so self-hosted users get pointed at the wrong server.
Impact: A self-hosted user who logged in with a profile and deploys using an environment API key has their deploy sent to the public cloud and fails with an authentication error instead of reaching their own instance.
Why the profile fallback never fires in practice
commonOptions declares -a, --api-url <value> with a default of CLOUD_API_URL (packages/cli-v3/src/cli/common.ts:24), so options.apiUrl is always a string. _deployCommand passes apiUrl: process.env.TRIGGER_API_URL ?? options.apiUrl (packages/cli-v3/src/commands/deploy.ts:274), which is therefore never undefined, making authConfig?.apiUrl in authenticateForDeploy dead code. The unit test that asserts the self-hosted fallback (packages/cli-v3/src/deploy/auth.test.ts:67-83) passes only because it omits apiUrl entirely.
By contrast, the login path in packages/cli-v3/src/commands/login.ts:253 resolves as env.TRIGGER_API_URL ?? authConfig?.apiUrl ?? opts.defaultApiUrl, i.e. the stored profile wins over the flag default — the opposite precedence to the new API-key path.
Prompt for agents
In packages/cli-v3/src/deploy/auth.ts, authenticateForDeploy resolves the API URL as `apiUrl ?? authConfig?.apiUrl ?? CLOUD_API_URL`. The intent (covered by a unit test) is that a self-hosted user's saved profile URL is used when no explicit URL was given. However, the caller in packages/cli-v3/src/commands/deploy.ts passes `process.env.TRIGGER_API_URL ?? options.apiUrl`, and `options.apiUrl` is always populated because commander declares `-a, --api-url` with a default of CLOUD_API_URL (packages/cli-v3/src/cli/common.ts). So the saved-profile fallback can never run and an API-key deploy on a self-hosted install goes to https://api.trigger.dev. Fix so that the precedence matches the login path (login.ts uses env var, then saved profile, then the flag/default): either only forward an explicitly-provided --api-url from the deploy command (e.g. detect whether the option came from the default via commander's getOptionValueSource, or drop the commander default), or treat CLOUD_API_URL as 'unset' when a profile URL exists.
Was this helpful? React with 👍 or 👎 to provide feedback.
| // User tokens bootstrap the environment's secret key, so gate them on | ||
| // env-tier read:apiKeys. Machine credentials are checked against the same | ||
| // permission before their presented key is returned below. | ||
| const denied = await authorizePatEnvironmentAccess({ | ||
| request, | ||
| authType: authenticationResult.type, | ||
| ability: | ||
| authenticationResult.type === "apiKey" && authenticationResult.result.ok | ||
| ? authenticationResult.result.ability | ||
| : undefined, | ||
| organizationId: environment.organizationId, | ||
| projectId: environment.project.id, | ||
| envType: environment.type, | ||
| resource: "apiKeys", | ||
| action: "read", | ||
| }); | ||
| if (denied) return denied; | ||
|
|
||
| // API-key callers already possess a valid environment credential. Reuse | ||
| // exactly what they presented instead of exchanging it for the root key. | ||
| const presentedApiKey = presentedApiKeyFromAuthentication(authenticationResult); | ||
| // env-tier read:apiKeys. A machine credential never receives that root key. | ||
| if (authenticationResult.type !== "apiKey") { | ||
| const denied = await authorizePatEnvironmentAccess({ | ||
| request, | ||
| authType: authenticationResult.type, | ||
| organizationId: environment.organizationId, | ||
| projectId: environment.project.id, | ||
| envType: environment.type, | ||
| resource: "apiKeys", | ||
| action: "read", | ||
| }); | ||
| if (denied) return denied; | ||
| } |
There was a problem hiding this comment.
🔍 Bootstrap endpoint now accepts any valid environment key, including restricted ones
The scope check was dropped for machine credentials: previously authenticateEnvironmentScopedApiRequest(request, "read", "apiKeys") required the key's ability to allow read:apiKeys, and authorizePatEnvironmentAccess re-checked it. Now authenticateEnvironmentBootstrapRequest only proves the key is valid. The echoed credential is the caller's own key, so no secret is escalated, but the response still leaks projectId, project name and the API origin to any restricted additional key (e.g. a TRIGGER_ONLY key). Worth confirming this widening is deliberate for all restricted presets and not just the deploy preset.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
trigger deploycan authenticate directly withTRIGGER_SECRET_KEY, including restricted environment API keys. API key credentials take precedence over user authentication and work for standard, native, and Preview deployments without login or user metadata.Design
Project environment bootstrap now echoes the exact environment key presented by the caller instead of exchanging an additional key for the root key. User token behavior and permission checks remain unchanged.
Preview branch creation accepts environment API keys with
write:branches, restricted to the key's own project and parent Preview environment. Deploy links remain available without user metadata, while deployment attribution stays optional.