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 packages/core/sdk/src/oauth-flow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ describe("oauth.start / oauth.complete", () => {
);
expect(Predicate.isTagged("OAuthStartError")(error)).toBe(true);
const startError = error as OAuthStartError;
expect(startError.message).toContain("must use a Workspace app");
expect(startError.message).toContain("must use an org-owned OAuth client");
}),
),
);
Expand Down
9 changes: 8 additions & 1 deletion packages/core/sdk/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,13 @@ export const makeOAuthService = (deps: OAuthServiceDeps): OAuthService => {
input: CreateOAuthClientInput,
): Effect.Effect<OAuthClientSlug, StorageFailure> =>
Effect.gen(function* () {
if (input.owner === "user" && deps.subject === "local") {
return yield* new StorageError({
message:
'User-owned OAuth clients are not supported on single-workspace hosts. Use owner "org" instead.',
cause: undefined,
});
}
// The `first-party:` namespace is reserved for config-declared apps — a
// stored row under it would be shadowed by (or worse, impersonate) the
// host's own app.
Expand Down Expand Up @@ -1423,7 +1430,7 @@ export const makeOAuthService = (deps: OAuthServiceDeps): OAuthService => {
});
if (!firstPartyFlow && input.owner === "org" && input.clientOwner === "user") {
return yield* new OAuthStartError({
message: "A Workspace connection must use a Workspace app.",
message: "An org connection must use an org-owned OAuth client.",
});
}
// Load the app by its EXPLICIT owner (the caller knows it — no derivation).
Expand Down
Loading