Skip to content

Commit d48b9b2

Browse files
nicktrnTrigger.dev RepoOps
authored andcommitted
fix(supervisor): mint-only pods need no verify key
Mono-RevId: 11065a66b1151a3b7f2b602b9450510acee881b3
1 parent bc99b6f commit d48b9b2

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎apps/supervisor/src/env.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,19 @@ describe("ed25519 workload token keys", () => {
405405
expect(Env.safeParse({ ...publicOnly, WORKLOAD_TOKEN_SECRET: "secret" }).success).toBe(true);
406406
});
407407

408+
it("lets a pod without the workload API mint with only a signing key", () => {
409+
const mintOnly = {
410+
...base,
411+
WORKLOAD_TOKEN_ENFORCEMENT: "enforce",
412+
TRIGGER_WORKLOAD_API_ENABLED: "false",
413+
WORKLOAD_TOKEN_SIGNING_KEY: ed25519Pems.privateKey,
414+
};
415+
expect(Env.safeParse(mintOnly).success).toBe(true);
416+
expect(Env.safeParse({ ...mintOnly, TRIGGER_WORKLOAD_API_ENABLED: "true" }).success).toBe(
417+
false
418+
);
419+
});
420+
408421
it("accepts an ed25519 signing key and refuses anything else", () => {
409422
expect(
410423
Env.safeParse({ ...base, WORKLOAD_TOKEN_SIGNING_KEY: ed25519Pems.privateKey }).success

‎apps/supervisor/src/env.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,15 @@ export const Env = z
528528
);
529529
if (
530530
data.WORKLOAD_TOKEN_ENFORCEMENT !== "disabled" &&
531+
data.TRIGGER_WORKLOAD_API_ENABLED &&
531532
!data.WORKLOAD_TOKEN_SECRET &&
532533
!hasCurrentPublicKey &&
533534
!hasCurrentSecretEntry
534535
) {
535536
ctx.addIssue({
536537
code: z.ZodIssueCode.custom,
537538
message:
538-
"WORKLOAD_TOKEN_SECRET, a WORKLOAD_TOKEN_SECRETS entry without a cutoff, or a WORKLOAD_TOKEN_PUBLIC_KEYS entry without runCutoff is required when WORKLOAD_TOKEN_ENFORCEMENT is not disabled",
539+
"WORKLOAD_TOKEN_SECRET, a WORKLOAD_TOKEN_SECRETS entry without a cutoff, or a WORKLOAD_TOKEN_PUBLIC_KEYS entry without runCutoff is required to verify tokens when TRIGGER_WORKLOAD_API_ENABLED is true and WORKLOAD_TOKEN_ENFORCEMENT is not disabled",
539540
path: ["WORKLOAD_TOKEN_SECRET"],
540541
});
541542
}

0 commit comments

Comments
 (0)