History

Fix SSR crash from the admin nav and add org API key revoke

The admin nav hook read orgMembersAtom, which is wrapped in refreshOnWindowFocus — a browser-only atom whose signal touches window at read time. Evaluating it during SSR threw ReferenceError synchronously in render, above the routed outlet, so the whole authenticated document fell back to client rendering and the landing page was blank on first paint. Give the atom an explicit server value so its read never runs on the server; the role reads as unknown during SSR and resolves client-side, and the nav still fails closed. Org API keys could be minted and listed but never revoked. Add DELETE /account/org-api-keys/:apiKeyId with the same admin gate as the mint, resolving ownership against the org's own keys so a member's personal key or a sibling org's key cannot be destroyed through it. Self-host and cloudflare refuse it as they already refuse the mint.

Rhys Sullivan committed 3 months ago

Commit 445a4cd1 parent 8bca26215 files · +454 −8Browse files

Showing the changes to apps/cloud/src/api (2 of 15 files). Show all

Unified · Split

2 files
  1. apps/cloud/src/api/protected-api-key-auth.node.test.ts +1 −0
  2. apps/cloud/src/api/protected-jwt-auth.node.test.ts +1 −0
apps/cloud/src/api/protected-api-key-auth.node.test.ts+1−0
@@ -25,6 +25,7 @@ const stubApiKeys = Layer.succeed(ApiKeyService)({ · 24 unmodified lines
2525 revokeUserKey: () => Effect.void,
2626 listOrgKeys: () => Effect.die("auth resolution test does not list org API keys"),
2727 createOrgKey: () => Effect.die("auth resolution test does not create org API keys"),
28+ revokeOrgKey: () => Effect.die("auth resolution test does not revoke org API keys"),
2829 });
2930
3031 const stubWorkOS = Layer.succeed(
apps/cloud/src/api/protected-jwt-auth.node.test.ts+1−0
@@ -42,6 +42,7 @@ const stubApiKeys = Layer.succeed(ApiKeyService)({ · 41 unmodified lines
4242 revokeUserKey: () => Effect.void,
4343 listOrgKeys: () => Effect.die("auth resolution test does not list org API keys"),
4444 createOrgKey: () => Effect.die("auth resolution test does not create org API keys"),
45+ revokeOrgKey: () => Effect.die("auth resolution test does not revoke org API keys"),
4546 });
4647
4748 const stubWorkOS = Layer.succeed(