Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/secrets/SecretRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ it.effect("a ref only works in the project it was entered for", () =>
const elsewhere = yield* service
.consume({ ref, projectId: ProjectId.make("project-other") })
.pipe(Effect.flip);
assert.include(elsewhere.message, "does not exist");
assert.equal(elsewhere.reason, "ref_wrong_project");
assert.equal(yield* service.consume({ ref, projectId }), "ghp_secret");
}),
),
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/secrets/SecretRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@ const make = Effect.gen(function* () {
const decoded = Option.flatMap(stored, (bytes) =>
decodeStored(new TextDecoder().decode(bytes)),
);
if (Option.isNone(decoded) || decoded.value.projectId !== input.projectId) {
return yield* new SecretRequestError({ reason: "ref_unavailable" });
if (Option.isNone(decoded)) return yield* new SecretRequestError({ reason: "ref_unavailable" });
// Before the expiry check, so a caller from another project never deletes the value.
if (decoded.value.projectId !== input.projectId) {
return yield* new SecretRequestError({ reason: "ref_wrong_project" });
}
if ((yield* Clock.currentTimeMillis) - decoded.value.savedAt > SECRET_REF_TTL_MS) {
yield* removeLogged(storeName(input.ref));
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/secretRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const SECRET_REQUEST_FAILURE_MESSAGES = {
read_failed: "Could not read the secret.",
ref_unavailable:
"That secretRef was already used or does not exist. Ask the user again with request_secret.",
ref_wrong_project:
"That secretRef was entered in another project. Ask with request_secret from a thread in the project that uses it.",
ref_expired: "That secretRef expired. Ask the user again with request_secret.",
consume_failed: "Could not use that secretRef. Try again.",
not_a_file_request:
Expand Down
Loading